0
How to get multiple inputs for different variables of class in python.
Ex. Get student name,roll no,father name, mother name for 5 students one by one as an input from user and store it in student class and print the student details when we enter roll number.
1 Réponse
+ 2
sathyanarayanan ,
to do so, you can use a loop, store the input in a list, then do further processing with the data.
but your task description is not as complete as it could be. so please give us a bit more information.
anyway, here a sample with 3 inputs using a for loop:
lst = [] # create a new list
for num in range(0,3): # use a loop for 3 iterations = 3 "data fields" like first name, last name, age
lst.append(input()) # get input and store it in list
print(lst) # output the content of the list