Hi
I have got the TypeError. I use lists at the same way in my other programs it works excellent, but just in this program I have got problem don’t know how to solve it?
Traceback (most recent call last):
File "E:\extra_b.py", line 42, in <module>
ordna(pile)
File "E:\extra_b.py", line 22, in ordna
new_num = num-1
TypeError: unsupported operand type(s) for -: 'list' and 'int'
import random
def lasin ():
c=int(input ("Enter an integer "))
return c
def dela(c):
sum=0
pile = []
while sum < c:
b = random.randrange (1, 10 - sum + 1)
pile.append(b)
sum += 1
print pile,sum
return sum, pile
def ordna(x):
b = 0
y = []
for num in x:
new_num = num-1
if new_num<0:
del new_num
else:
y.append(new_num)
b+=1
y.append (b)
y.sort()
y.reverse ()
print " ".join(map(str,y))
return y
c=lasin ()
pile=dela(c)
ordna(pile)
Thanks a lot for your help.