Taking List as user input in Python
The following is one of the ways to take 'list' as user input.
The following is one of the ways to take 'list' as user input.
# defining empty list
uList = []
# defining the number of elements in the list
nList = int(input("List of how many elements? "))
print("Now enter the elements of your list one by one.")
# taking elements of the list as user input
for i in range(0,nList):
element = int(input())
uList.append(element)
print(f"The original list is {uList}")
Comments
Post a Comment
Write something to CodeWithAbdur!