my_dictionary = {name:[],age:[],course:[]}
for i in student_list:
my_dictionary.name.append(i[0])
my_dictionary.age.append(i[1])
my_dictionary.course.append(i[2])
This my below code is running fine but I want to go 2 steps further but becoming very difficult.
student_details = []
space = int(input('Please enter the number of student to be added: '))
for n in range(space):
data = [
input('enter your name: '),
input('enter your age: '),
input('enter your course: ')
]
student_details.append(data)
print(student_details)
print('{:<12} (:<12} {:<12}'.format('NAME', 'AGE', 'COURSE'))
details1 = {i : (student_details[i] for i in range(5)}
for key, value in details1.items():
name, age, course = value
print('{:<12} (:<12} {:<12}'.format(name, age, course))
While the code gives me result, I’m finding it difficult to do the following:
If I set the space to range(5), it means that I will have to input name, age and course for 5times, how can I use break statement to stop the process EVEN if i did not enter the value 5times without changing the range from the code and then still print whatever that is input maybe at range(3)?