Skip to content

Commit c885583

Browse files
Update Conditionals.py
1 parent ccb4c95 commit c885583

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Conditionals.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,36 @@
403403

404404
else:
405405
print('Type the right vales please!')
406+
407+
'''-----------------------------------------------------------------------------'''
408+
409+
# This little flip flop game is a great example of how the conditional while-loop works.
410+
# The 'else' statement executes/runs when the user types the wrong keys, and the
411+
# while-loop iterates/repeats over again while ignoring the 'break' statement.
412+
413+
print('\nWelcome to Flip! Flop!')
414+
415+
print('\nPlease type the words "flip" or "flop", then press (ENTER)')
416+
417+
print('\nWhen you give up, press (ENTER) to quit playing Flip! Flop!')
418+
419+
while True:
420+
flip=input('\nFlip? or Flop? ').strip()
421+
422+
if flip=='flip':
423+
print('\nFlop!')
424+
425+
elif flip=='flop':
426+
print('\nFlip!')
427+
428+
elif flip=='':
429+
print('\nThanks for playing Flip! Flop!')
430+
break
431+
432+
else:
433+
print('\nYou can\'t cheat now! Do you flip? or do you flop?')
434+
435+
input('\nEnd of program. Press Enter to quit.')
406436

407437
'''-----------------------------------------------------------------------------'''
408438

0 commit comments

Comments
 (0)