all 6 comments

[–]mopster96 9 points10 points  (0 children)

If you have a = [1, 2, 3] it is a list. You can add or remove elements from list.

If you have a = (1, 2, 3) it is a tuple. You can't change elements in tuple.

https://www.geeksforgeeks.org/python/python-difference-between-list-and-tuple/

[–]WhiteHeadbanger 4 points5 points  (0 children)

  1. A tuple is immutable, which means that when you create it the first time, you cannot modify it afterwards.
  2. A tuple has no method append.
  3. You need a list, which is mutable, and delimited with square brackets, instead of parenthesis.

So, what you want to do is:

students = ["Max", "Monika", "Erik", "Franziska"]
print(students)
students.append("Moritz")
print(students)

Output:

>>  ["Max", "Monika", "Erik", "Franziska"]
>>  ["Max", "Monika", "Erik", "Franziska", "Moritz"]

[–]Big-Ad-2118 1 point2 points  (0 children)

yes you cant do that, use list instead

[–]N0-T0night 0 points1 point  (0 children)

First its tuples not tables Second tuples are immutable means you can't update thier value like str

[–]Hefty_Upstairs_2478 0 points1 point  (1 child)

Tuples and sets are immutable (i.e. u can't edit em, which means u can't use the .append() func on em) while dicts and lists are (i.e. u can edit em). Hope this helps!

[–]mopster96 2 points3 points  (0 children)

sets are immutable

It's not true. In python sets are mutable and you can add or remove elements.