使用此代码:
<Button
我收到语法错误:
<CustomButton
答案 0 :(得分:0)
Python块可与您一起使用缩进,并且每当您要从函数返回某些内容时,return
应该与其余函数体相同。
像这样去
def get_filters():
"""
Asks user to specify a city, month, and day to analyze.
Returns:
(str) city - name of the city to analyze
(str) month - name of the month to filter by, or "all" to apply no month filter
(str) day - name of the day of week to filter by, or "all" to apply no day filter
"""
print('Hello! Let\'s explore some US bikeshare data!')
# TO DO: get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs
while True:
city = input('Which city do you want to explore Chicago, New York or Washington? \n').lower()
if city in CITIES:
break
# TO DO: get user input for month (all, january, february, ... , june)
month = get_user_input('All right! now it\'s time to provide us a month name''or just say \'all\' to apply no month filter. \n(e.g.all, january, feburary, march, april, may, june) \n> ',MONTHS)
# TO DO: get user input for day of week (all, monday, tuesday, ... sunday)
day = get_user_input('One Last thing. Could you type one of the week day you want to analyse?''You can type \'all\' again to apply no day filter. \n(e.g. all, monday, sunday) \n>',DAYS)
print('-'*40)
return city, month, day