Sep-29-2019, 05:27 AM
Hi everyone!
I'm new to python and was hoping to get some help with the code below.
I've worked out that the error pops up whenever I try to finish the second 'if, else' statement.
I am not sure how to fix it though, and some help would be greatly appreciated.
I'm new to python and was hoping to get some help with the code below.
I've worked out that the error pops up whenever I try to finish the second 'if, else' statement.
I am not sure how to fix it though, and some help would be greatly appreciated.
def coin_flip(coinbet, h_or_t): flip = 0 if (h_or_t == "H"): guess = heads elif (h_or_t == "T"): guess = tails else: print("Please write in correct format") flip = random.randit(1, 2) if (flip == 2) and (guess == tails): print("You flipped tails! Nice job!") print("You won " + str(coinbet*2) + "!") elif (flip == 1) and (guess == heads): print("You flipped heads! Nice job!") print("You won " + str(coinbet*2) + "!" else: print("test")
File "script.py", line 22 else: ^ SyntaxError: invalid syntax