Kevin Robinson
Kevin Robinson

Reputation: 1

My code keeps saying, "Attribute Error: 'int' has no attribute 'append'." How do I fix this?

My project is to create a while loop asking the user to enter numbers. Then, they are to add them to the list:

nums = 0
limit = 0
my_list = [ ]
while limit < 11:
    nums= int(input("Enter a number: "))
    nums.append(nums)

    if nums == 0:
        break

Upvotes: 0

Views: 290

Answers (1)

Kostas
Kostas

Reputation: 1903

my_list.append(nums);

nums is an integer. It doesn't have methods.

Upvotes: 1

Related Questions