+ 1
Python help me please
I have written a code by using conditionals if and if else statement the code format is same for if condition only value changes how to create a template using functions such that I can use functions to perform the condition..
1 Odpowiedź
+ 1
You can create a varable before the function to make it globally accessible . You can then change the value contained in the variable to what is required.
Foo=0 #creates a container for the value
#the function you want to reuse
Def my_func(foo):
If (some condition involving foo):
#do something
elif(another condition)
#do something
Foo = input("enter foo value: ") #assigns new value to foo
my_func(foo)