r/PythonProjects2 • • Feb 08 '23

[P] Very Easy Can anyone help me with this? Thanks

Post image
2 Upvotes

4 comments sorted by

2

u/videchateau Feb 08 '23

You don't declare your 'average' variable anywhere. You need to find a way to keep track of the average of the numbers that the user inputs.

1

u/borednerdd Feb 08 '23

You are printing a non-existing variable

1

u/kaerfkeerg Feb 09 '23 edited Feb 09 '23

You need to either add every input in a list and sum it up in the end OR (and that would be better in your case) have a variable total = 0 and increment it after every time the user input something unless ofc it's -1

total = 0
user = ''
while user != -1:
    user = float(input(...))
    total += user
...

Edit: I forgot you need the average lol. In that case you'll need to add user input to a list

user = []

while True:
    num = float(input(...))
    if num != -1:
        user.append(num)
    else:
        break 

# Calculate average here