0
HOW CAN I DO SO, THAT "X" WILL BE IN LIST?
list = ["Momo", ""] x = input("Enter name: ") list + x print(list)
4 Answers
+ 3
list.append(x)
I would recommend changing the list name to lis or li because it shadows the object list which leads to errors.
+ 3
Joe another method to do this.
list=[1,2,3]
x=input('Enter something= ')
list+=[x]
print(list)
but TurtleShell approach is good because append method has less time complexity than simply combine two list with each other.
+ 1
thanks!
0
thanks!