It seems like all the functions are executed then one() is being executed. How do i go to function one() without executing all the other functions?
sample.py
#!/usr/bin/python
def zero():
print("This is func zero")
return "Test"
def one():
print("This is func one")
return True
def two():
print("This is func two")
x = 7
print("%d" % x)
return False
def numbers_to_strings(argument):
switcher = {
0: zero(),
1: one(),
2: two(),
}
return switcher.get(argument, "nothing")
# Driver program
if __name__ == "__main__":
argument=1
print(numbers_to_strings(argument))
Output
This is func zero
This is func one
This is func two
7
True
Expected
This is func one
True
Or is there an explanation why it works this way? Thanks in advance! New to Python btw