I have this piece of code, and everything works fine, and now I am trying to build the IF statement correctly.
I only have one ASCEND function right now, so yea, the IF statement references it for ascend and descend, so ignore that piece. When I typed in "r" as my 'answer', it still ran the rainSortAscend.
Can you help point me in the right direction for the IF statement?
answer = ""
print('Do you want the rainfall to be ascending or descending?')
answer = input('Answer with "A" or "D"' + answer)
def rainSortAscend(monthRainfall):
for number in range(len(monthRainfall)-1,0,-1):
for i in range(number):
if monthRainfall[i]>monthRainfall[i+1]:
temp = monthRainfall[i]
monthRainfall[i] = monthRainfall[i+1]
monthRainfall[i+1] = temp
if answer == 'a' or 'A':
rainSortAscend(monthRainfall)
print(monthRainfall)
elif answer == 'd' or 'D':
ranSortAscend(monthRainfall)
else:
print('Start over and type in the specified "A" or "D" option')
Aucun commentaire:
Enregistrer un commentaire