'''
#Kevin Solis Gomez
#October 17,2022
#Module 7 Section 4.1
#Today I learned how to nest conditionals and loops
'''
# simplified example
# [ ] review the code then run and following the flowchart paths
# ***TIP:*** click in input box before typing
sandwich_type = input('"c" for Cheese or "v" for Veggie Special: ')
if sandwich_type.lower() == "c":
# select cheese type
cheese_type = input('"c" for Cheddar or "m" for Manchego: ')
if cheese_type.lower() == "c":
print("Here is your Cheddar Cheese sandwich")
else:
print("Here is your Manchego Cheese sandwich")
else:
print("Here is your Veggie Special")
Here is your Manchego Cheese sandwich
# full example: handling some invalid input and elif statement
# [ ] review the code then run following the flowchart paths including **invalid responses** like "xyz123"
# ***TIP:*** click in input box before typing
print("Hi, welcome to the sandwich shop. Please select a sandwich.")
sandwich_type = input('"c" for Cheese or "v" for Veggie Special: ')
# select sandwich type sandwich_type = input('"c" for Cheese or "v" for Veggie Special: ')
print()
if sandwich_type.lower() == "c":
# select cheese type
print("Please select a cheese.")
cheese_type = input('"c" for Cheddar or "m" for Manchego: ')
print()
if cheese_type.lower() == "c":
print("Here is your Cheddar Cheese sandwich. Thank you.")
elif cheese_type.lower() == "m":
print("Here is your Manchego Cheese sandwich. Thank you.")
else:
print("Sorry, we don't have", cheese_type, "choice today.")
elif sandwich_type.lower() == "v":
print("Here is your Veggie Special. Thank you.")
else:
print("Sorry, we don't have", sandwich_type, "choice today.")
print()
print("Goodbye!")
Hi, welcome to the sandwich shop. Please select a sandwich.
Please select a cheese.
Here is your Cheddar Cheese sandwich. Thank you.
Goodbye!
say_hello = input('Do you want to say hello?(Yes/No)')
if say_hello.title().startswith('Y'):
fs_hello = input('Full or Short')
if fs_hello.title().startswith('F'):
print('Hello!')
elif fs_hello.title().startswith('S'):
print('Hi!')
else:
print('Did you ask "Hello" or "Hi"?')
elif say_hello.title().startswith('N'):
print('(Nods in hello)')
else:
print('what?')
Hello!
def guess_bird_game(bird1, bird2, bird3):
bird_list = 'Seagull, Goose, Duck, Owl, Swans'
if bird1.title() in bird_list != True:
if bird2.title() in bird_list != True:
if bird3.title() in bird_list != True:
print('Sorry, You losted!')
else:
print('Good Job, 3rd try! :)')
else:
print('Great Job, 2nd try! :D')
else:
print('Did you cheat or are you man of code? :l')
bird1_input = input('Put your first guess for the bird')
bird2_input = input('Put your second guess for the bird')
bird3_input = input('Put your third guess for the bird')
guess_bird_game(bird1_input, bird2_input, bird3_input)
Sorry, You losted!