Reputation: 11
How do I print the function 'play' in the if statement on line 5?
print("Deal 'Em\nby Imago Games")
print("1. Play\n2. Credits")
select = input()
if select == 1:
def play()
elif select == 1:
print("Bye")
def play():
print("Welcome to Deal 'Em\nLet me teach you the basics!")
Upvotes: 0
Views: 274
Reputation: 14369
There are three major problems in your code:
play()
is defined before usage. You have to define the function earlier in your code.play()
without def
elif
has the same condition as the if
and will never be executedUpvotes: 3
Reputation: 1793
Instead of def play()
on line 5, use play()
to simply call the function. Also, you should work on the structure of your code and place all the function definitions before calling them.
Upvotes: 0
Reputation: 58
Just leave it as play(), the print is already inside the function
Upvotes: 0
Reputation: 2917
You can put either just play()
on line 5 (remove the def
) or change the play
function to return the string instead of printing it. def
is only used when you define the function, not when you call it.
Upvotes: 0