File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 403
403
404
404
else :
405
405
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 ('\n Welcome to Flip! Flop!' )
414
+
415
+ print ('\n Please type the words "flip" or "flop", then press (ENTER)' )
416
+
417
+ print ('\n When you give up, press (ENTER) to quit playing Flip! Flop!' )
418
+
419
+ while True :
420
+ flip = input ('\n Flip? or Flop? ' ).strip ()
421
+
422
+ if flip == 'flip' :
423
+ print ('\n Flop!' )
424
+
425
+ elif flip == 'flop' :
426
+ print ('\n Flip!' )
427
+
428
+ elif flip == '' :
429
+ print ('\n Thanks for playing Flip! Flop!' )
430
+ break
431
+
432
+ else :
433
+ print ('\n You can\' t cheat now! Do you flip? or do you flop?' )
434
+
435
+ input ('\n End of program. Press Enter to quit.' )
406
436
407
437
'''-----------------------------------------------------------------------------'''
408
438
You can’t perform that action at this time.
0 commit comments