Append function

Hi can anyone help me?

I was trying to append a number into the list on jupyter notebook but it didn’t work and I’m stuck. (I did restart the jupyter note book but it dorps the same error.)

So my code was:

a = {44, 9, -10}

print(a)
{9, 44, -10}

a.append(1)
AttributeError Traceback (most recent call last)
in ()
----> 1 a.append(1)

AttributeError: ‘set’ object has no attribute ‘append’

because the brackets arent square.
change the bracket to square bracket and it will work, correct me if im wrong

Hi There, thank you for helping me out.

Here are the results:
a.append[1]

AttributeError Traceback (most recent call last)
in ()
----> 1 a.append[1]

AttributeError: ‘set’ object has no attribute ‘append’

or:

a.append{1}
File “”, line 1
a.append{1}
^
SyntaxError: invalid syntax

The weird thing is that my this code (a.append(1)) is exactly the same to a person’s but it just wouldn’t work on my jupyter notebook even I restarted it again and again.

I downloaded this person’s code and run it on my jupyter notebook and it’s working.

your code needs to look like this:

<p> 
 a = [44, 9,-10]
print(a)

a.append(1)
print(a)

I just found out the rel problem is from the first code:

I wrote a = {44, 9, -10}, but it should be a = [44, 9, -10].

Thank you anyway!

Yes I also just found out. Thank you very much!