0
Can we input in list through user at run tym?
2 Answers
+ 6
List is mutable, so sure. You can either use a simple addition, the .append() method or assignment to replace existing list element with a new one.
Example:
lista = ['123', 'abc', 888]
# option 1:
lista += input()
# option 2:
lista.append(input())
# option 3
lista[2] = input()
The first two would each add a new element specified by the user, while the third option replaces 888 with the new value put in by the user.
+ 1
you can try:
lista=[input(), input()]
Just remember that input Will be a string, so you need to convert to the desired type.