Created
February 19, 2020 17:31
-
-
Save mayankdawar/f51adcde0f8c0f85440fc4e88ce7da13 to your computer and use it in GitHub Desktop.
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 res…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
percent_rain = [94.3, 45, 100, 78, 16, 5.3, 79, 86] | |
resps = [] | |
for i in percent_rain: | |
if i > 90: | |
resps.append("Bring an umbrella.") | |
elif i >80: | |
resps.append("Good for the flowers?") | |
elif i > 50: | |
resps.append("Watch out for clouds!") | |
else: | |
resps.append("Nice day!") |
I tried this but it did not work; not sure what is wrong
percent_rain = [94.3, 45, 100, 78, 16, 5.3, 79, 86]
resp =[]
if percent_rain < 90:
resp = ("bring an umbrella")
output (resp)
elif percent_rain > 80:
output (resp + ("Good for the flowers?"))
elif percent_rain<50:
output (resp +("Wacth out for clouds"))
else :
output (resp +("Nice day!"))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works 100%