Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36284
| References | <76529b4c-fbc7-4d6d-89a5-160545448ff2@googlegroups.com> |
|---|---|
| Date | 2013-01-06 12:39 -0800 |
| Subject | Re: How do you call a function several times in this context?? |
| From | Benjamin Kaplan <benjamin.kaplan@case.edu> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.184.1357505147.2939.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On Jan 6, 2013 12:33 PM, "kofi" <ghanashirts4sale@gmail.com> wrote:
>
> Using python 3.1, I have written a function called "isEvenDigit"
>
> Below is the code for the "isEvenDigit" function:
>
> def isEvenDigit():
> ste=input("Please input a single character string: ")
> li=["0","2","4", "6", "8"]
> if ste in li:
> print("True")
> else:
> print("False")
>
> I am now trying to write a function that takes a string as an argument
and makes several calls to the isEvenDigit function in order to calculate
and return the number of even digits in the string.How do i do this please?
This is what i have done so far.
>
> def isEvenDigit2():
> number = input("Enter a digit: ")
Use a loop and call the function in the body of the loop. In this case, you
would use a for loop iterating over number. If you don't know how to use a
for loop, I recommend you do the tutorial at
http://docs.python.org/3.3/tutorial/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How do you call a function several times in this context?? kofi <ghanashirts4sale@gmail.com> - 2013-01-06 12:26 -0800
Re: How do you call a function several times in this context?? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-01-06 12:39 -0800
Re: How do you call a function several times in this context?? Alister <alister.ware@ntlworld.com> - 2013-01-06 21:23 +0000
Re: How do you call a function several times in this context?? Jason Friedman <jason@powerpull.net> - 2013-01-06 14:33 -0700
Re: How do you call a function several times in this context?? Alister <alister.ware@ntlworld.com> - 2013-01-06 22:35 +0000
Re: How do you call a function several times in this context?? Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-06 17:01 -0500
csiph-web