m 30/10/2019 08:55, ferzan saglam escreveu:
total = 0
while True:

   print('Cost of item')
   item = input()

   if item != -1:
     total += int(item)
   else:
     break

print(total)
The program does not stop because its code does not contain any deals that make the loop stop after 10 rounds. You can simply implement a counter that counts the number of times the loop has passed.

You also did not convert item to int to make the comparison.

total = 0
rounds = 0
while rounds <= 10:

  print('Cost of item')
  item = input()

  if int(item) > -1:
    total += int(item)
    rounds += 1
  else:
    break

print(total)

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to