-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewUser.py
40 lines (29 loc) · 1.23 KB
/
NewUser.py
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
37
38
39
40
class NewUser:
def __init__(self, name_label, age_label, cnic_label):
self.__name_label = name_label
self.__age_label = age_label
self.__cnic_label = cnic_label
with open("Students.txt", "w") as students:
students.write("\t\t{0}\t\t{1}\t\t{2}".format(name_label,age_label,cnic_label))
def insertUserData(self, noOfEntries):
profiles = []
for n in range(noOfEntries):
name = input("{0} -- Student Name :".format(n))
age = input(" {0} -- Student Age :".format(n))
cnic = input("{0} -- Student Cnic :".format(n))
print("\n\n")
profiles.append(
{
"name": name,
"age": age,
"cnic": cnic
}
)
print("*** Writing Data To File ***")
self.writeDataToFile(profiles)
def writeDataToFile(self, profiles):
for profile in profiles:
with open("Students.txt", "a") as students:
students.write("\n\t\t\t{0}\t\t\t{1}\t\t\t{2}".format(profile["name"], profile["age"], profile["cnic"]))
data = NewUser("Name","Age","Cnic")
data.insertUserData( int(input("Enter Number Of Entries : ")))