-
Notifications
You must be signed in to change notification settings - Fork 0
/
code 5
37 lines (26 loc) · 1.13 KB
/
code 5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import csv
def write_into_csv(info_list):
with open('student_info.csv','a',newline='') as csv_file:
writer = csv.writer(csv_file)
if csv_file.tell() == 0:
writer.writerow(["Name","Age","Contact Number","E-Mail ID"])
writer.writerow(info_list)
if__name__=='__main__':
condition = True
student_num = 1
while(condition):
student_info = input("Enter student information for student #{} in the following format(Name Age Contact_number E-Mail_ID):".format(student_num))
#split
student_info_list = student_info.split(' ')
print("\nThe entered information is -\nName: {}\nAge: {}\nContact_number: {}\nE-Mail ID: {}".format(student_info_list[0],student_info_list[1],student_info_list[2],student_info_list[3]))
choice_check = input("Is the entered informaton correct? (Yes/No):")
if choice_check == "Yes":
write_into_csv(student_info_list)
condition_check = input("Enter (Yes/No) if you want to enter information for another student:")
if condition_check == "Yes":
condition = True
student_num = student_num + 1
elif condition_check == "No":
condition = "False"
elif choice_check == "No":
print("\nPlease re-enter the values!")