-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoinflip.py
More file actions
26 lines (25 loc) · 844 Bytes
/
coinflip.py
File metadata and controls
26 lines (25 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import random
heads = 1
tails = 0
valid_guesses = [heads, tails]
correct_statement = "Correct! The coin flip landed "
incorrect_statement = "incorrect! The coin flip landed "
guess_list = []
coin_flip_otcme = random.randint(0,1)
for guess in valid_guesses:
def coin_flip(user_guess):
if coin_flip_otcme == user_guess:
if user_guess == heads:
return (correct_statement + heads + "!")
else:
return (correct_statement + tails + "!")
elif coin_flip_otcme == 0:
if user_guess == tails:
return (correct_statement + tails + "!")
elif user_guess == tails:
return(correct_statement + tails + "!")
print(coin_flip(heads))
print(coin_flip(tails))
print(coin_flip("bat"))
print(coin_flip("Heads"))
print(coin_flip("Tails"))