I'm very, very new to computer programming. I started writing a very simple script that gives you directions to someone's house when you input their name:
# Users and Directions:
davids_house = "Directions to David's home from X... \n East on Y, \n South on Z," \
" \n West on A, \n South on B, \n first C on the right."
bannons_house = "bannons directions here"
# Asking the user where he/she would like to go:
destination = input("Where would you like to go? ")
# Reads out a set of directions depending on what name was picked:
if destination in ['Davids_House', 'davids_house', 'Davids_house', 'davids_House']:
print(davids_house)
if destination in ['Bannons_House', 'bannons_house', 'Bannons_house', 'bannons_House']:
print(bannons_house)
else:
print("Sorry, that's not an option.")
Whenever I run this program and reach the point where it gives directions, I'll give it a valid input of say 'davids_house'. It will print out the directions, but it will ALSO run the 'else' statement. When I type in an invalid value, it does what I want it to do and ONLY displays "Sorry, that's not an option."
I was under the impression that the 'else' will not run unless the 'if' statement isn't satisfied with a valid value.
I haven't been able to find anything like this, surprisingly, on other forums. I've found questions/answers similar to what I'm looking for, but nothing has actually fixed my issue in this specific case. What am I doing wrong?
elifinstead of anotherif