Mar-22-2019, 10:01 PM
I'm completely flummoxed by this one.
Homework question follows:
Create an empty list called resps. Using the list percent_rain, for each percent, if it is above 90, add the string ‘Bring an umbrella.’ to resps, otherwise if it is above 80, add the string ‘Good for the flowers?’ to resps, otherwise if it is above 50, add the string ‘Watch out for clouds!’ to resps, otherwise, add the string ‘Nice day!’ to resps. Note: if you’re sure you’ve got the problem right but it doesn’t pass, then check that you’ve matched up the strings exactly.
Here's my attempt:
[error]
SyntaxError: bad input on line 5
[error]
Homework question follows:
Create an empty list called resps. Using the list percent_rain, for each percent, if it is above 90, add the string ‘Bring an umbrella.’ to resps, otherwise if it is above 80, add the string ‘Good for the flowers?’ to resps, otherwise if it is above 50, add the string ‘Watch out for clouds!’ to resps, otherwise, add the string ‘Nice day!’ to resps. Note: if you’re sure you’ve got the problem right but it doesn’t pass, then check that you’ve matched up the strings exactly.
Here's my attempt:
percent_rain = [94.3, 45, 100, 78, 16, 5.3, 79, 86] resps = [] for x in percent_rain: if x>90: if x = True: resps.append("Bring an umbrella.") elif x>80: if x = True: resps.append("Good for the flowers?") elif x>50: if x = True: resps.append("Watch out for clouds!") else: resps.append("Nice day!") print(resps)Here's error message:
[error]
SyntaxError: bad input on line 5
[error]