Issue
I wrote those codes and they were running just fine, and gives the correct answers, but suddenly they began to give me wrong answers or get to next code directly, I don't know what happened? when entering city correctly, tells me to choose from available! and in month: the month is written correct but still not in months and also with days???!
enter code here
print('Hello! Let\'s explore some US bikeshare data!')
# get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs
cities = ['chicago', 'new york', 'washington']
city = input('Choose a city: \n >').lower()
if city not in cities:
city = input('Choose from available Cities: Chicago, New York or Washington: \n >').lower()
if city == 'new york':
city = 'new york city'
# get user input for month (all, january, february, ... , june)
months = ['all', 'January', 'Feburary', 'March', 'April', 'May', 'June']
month = input('Please select month or for all months type "all": \n >').lower()
if month not in months:
month = 'all'
print("This month is not available so it's gonna be all")
# get user input for day of week (all, monday, tuesday, ... sunday)
days = ['all', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
day = input('Please Choose specific day or for all days type "all": \n >')
if day not in days:
day = 'all'
print("That day isn't available, so it's gonna be all")
Solution
month = input('Please select month or for all months type "all": \n >')
remove the lower() else change the elements in months list to lowercase.
Answered By - soubhiksen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.