Taking List as user input in Python

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}")
Python

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

Making GUI Calculator in Tkinter Python

Unlocking Web Design: A Guide to Mastering CSS Layout Modes