Hi am new just started Computer Science at London Met we have programming in Python. In this code am trying to add items to already existing appended list list.append([student_name, student_age, student_sex]) from user input student_grade. How can i do this for each item in range. SO next time i print student_grade will be added to at the end of statement in form {each_item[3]} and 3 in the case will be student_grade ?
thanks in advance
from io import StringIO
import sys
number_student = int(input("How many students You want to add: "))
list = []
for i in range(0, number_student):
student_name = input("Whats Your name student? ")
student_age = input("Whats Your age student? ")
student_sex = input("Female or male? ")
list.append([student_name, student_age, student_sex])
comment withhash student_1 = (student_name, student_age + "years old", student_sex)
for each_item in list:
print(f"Student name is {each_item[0]}, you are {each_item[1]} years old and you are {each_item[2]}")
student_grade = input("Add student grade: ")
list.extend(["student_grade"])
#list.extend([student_grade])
for each_item in list:
print(f"Student name is {each_item[0]}, you are {each_item[1]} years old and you are {each_item[2]}, and your grades are", student_grade)
comment withhash student_1
? You never usestudent_1
anywhere.list.extend()
. You need to useeach_item.append()