Feb-10-2020, 09:07 PM
response = input('Enter Yes No or Maybe') if response == "Yes": print('Alright then') elif response == "No": print('OK') else print('Whenever you decide') if response == "Yes": print('Alright then') if response == "No": print('OK') if response == "Maybe": print('Whatever you like')These may look similar, but do have different behavior. In the first case, responds as you expect to Yes and No, and everything else defaults to the else which is Maybe. In the second case, it responds to Yes, No, and Maybe but will not respond to anything else, like 'Coconut'. The first example will treat Coconut as Maybe. So, it all depends on your particular switching needs.