I want to find the the minimum and maximum value with loop without using the list function. The code works perfectly I just get the same maximum as minimum value?
import math
Choice= ''
sum=0
while Choice!='3':
print ('1- Amount of rain per month')
print('2- See statistic for this year')
print('3- Finish')
val= input ('Your choice:')
if Choice== '1':
for x in range (1,13):
rain= input ('Give the number of month'+ str(x)+ ':')
rain=float(rain)
sum+=rain
print('Sum:', sum)
if val== '2':
print('The average in a year:', sum/12)
minVal=0
minVal<rain
minVal=rain
print('Minimum value:', minVal)
maxVal=0
rain > maxVal
maxVal=rain
print('Maximum value:', maxVal)
if Choice=='3':
print('Finish')
rain > maxValis a comparison that returns True or False ...but you do nothing with it. You also only have the total sum - not the single month-values stored. You would need to store the values of the months into a list - then you can loop over the list and get the min and max values. Or you define min/max first and on input when new jnumber is bigger/lower adjust your "memorized" min/max-values. Fixing this would mean to rewrite your whole code - you might want to browse some tutorials to get the hang of lists and loops.