How do you call a function several times in this context??

Alister alister.ware at ntlworld.com
Sun Jan 6 16:23:32 EST 2013


On Sun, 06 Jan 2013 12:26:40 -0800, kofi 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: ")
you need to investigate passing parameters to and from function

as you are obviously a beginner I don't want to give you the answer to 
your task but hopefully steer you in the right direction.

examine the code below & see if you can understand how it is working & 
how to apply it to your current project

def double(value):
	result
	return result

number=input('type a number')
print (double(int(number)))

this program is for explanation only and a function this simple should 
never be used in a real program, it is functionally equivalent to

number=input('type a number')
print (int(number)*2)

-- 
Alex Haley was adopted!



More information about the Python-list mailing list