-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPioneers_Program.py
More file actions
60 lines (36 loc) · 1.98 KB
/
Pioneers_Program.py
File metadata and controls
60 lines (36 loc) · 1.98 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#program lists names from Pioneers.txt and takes input
#of name from user and outputs the persons accomplishment
#create loop condition for repeition
inputNewName = ('y','Y','Yes','yes')
goAgain = 'y'
while goAgain in inputNewName:
def main ():
def getList(textFile):
inputFile = open(textFile, "r") #function will separate the textfile
lineByLine = inputFile.readlines() #line by line
allData=[]
for currentLine in lineByLine: #and put into a list separated by comma, names[0] accomplishments[1]
currentList = currentLine.split(',')
allData.append(currentList) #[[Charles Babbage,is called the father of the computer],[Augusta Ada Byron,was the first computer programmer]]
return allData
def giveNames(allData):
nameList = []
for singleData in allData : #function will take the names and put them into a different list and return them for user to see
nameList.append(singleData[0])
return nameList
def getAccomp(inputedName,allData):
for currentList in allData:
if inputedName == currentList[0]: #function will take the name inputed and return the corresponding accomplishment
return currentList[1]
return "No match found. Please enter valid name!"
List = getList("Pioneers.txt")
names = giveNames(List)
for name in names :
print(name)
inputedName = str(input("\nEnter a name from above list : "))
inputedName = inputedName.title()
accomp= getAccomp(inputedName,List)
print(accomp)
main()
#user is able to input another name if desired
goAgain = input('Want to know about another person? Press Y ')