Hi everyone,
I'm new to posting, but I've been coming here to search for help for some time now. I'm working on some homework and have come to an impasse. I'm not here for straight-up solutions, just a little help, as I've already got the program 99% complete. In the program I'm trying to scale a list of numbers, but my method for identifying the maximum element is obviously flawed. Could someone help me spot why this program does not think that 100 is greater than 95?
f=open('list.txt','r')
numlist=f.readlines()
len = len(numlist)
max = (numlist[0])
min = (numlist[0])
print "original list: "
for n in range(1,len):
print numlist[n]
if numlist[n]>max:
max=(numlist[n])
if numlist[n]<min:
min=(numlist[n])
newlist = []
for n in range(0,len):
x = float((int(numlist[n]) - float(min))/(int(max)-float(min)))
newlist.append(x)
print "min: "
print min
print "max: "
print max
print "scaled list: "
print newlist
The "list.txt" file is just:
80
0
60
25
50
70
75
100
90
95
Thanks in advance!