Python Forum
outcome 0 but impossiblenumbers change
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
outcome 0 but impossiblenumbers change
#1
i= 1
top_hat= []
while i<=5:
    try:
        top_hat.append(int(input('Please enter your top hat score: ')))
        i+=1
    
    except:
        print('Please enter valid number: ')

print(top_hat)

top_hat_total=[]
for x in top_hat_total: 
        top_hat_total.append(x*(2/100))

print('your total percentage from top hat is: '  + str(sum(top_hat_total))) 
No matter what i enter for numbers at the end it prints out as 'your total percentage from top hat is:0'
Why?
Reply
#2
you are looping top_hat_total which is an empty list
for x in top_hat_total:
did you mean to loop top_hat
for x in top_hat:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Not the expected outcome christopher3786 1 1,553 Jun-23-2020, 07:16 AM
Last Post: bowlofred
  Python program that list all possible football outcome combinations lukorir 5 8,887 Oct-17-2019, 04:05 AM
Last Post: steve_shambles
  no outcome is printing helpme 2 2,284 Mar-07-2019, 02:15 PM
Last Post: helpme

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020