We often encounter a situation when we need to take number/string as input from the user. In this article, we will see how to get as input a list from the user.
Input : n = 4, ele = 1 2 3 4 Output : [1, 2, 3, 4] Input : n = 6, ele = 3 4 1 7 9 6 Output : [3, 4, 1, 7, 9, 6]
Code #1: Basic example
Code #2: With handling exception
Code #3: Using
Code #4: List of lists as input
Code #5: Using List Comprehension and Typecasting
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course