I am aware that you can call a Module in Python within itself, but can you also cancel it within itself? This code is supposed to only display that the name was found, one time. It continues to print until I interrupt the program with and get KeyboardInterrupt
from the IDLE. Can I have some help on what I should put in or change? P.S.: I have Python 3.4.2
from array import *
s = ["Turner", "Philips", "Stevenson", "Jones", "Gonzalez",
"Whitaker", "Bruner", "Webster", "Foster", "Anderson",
"Klein", "Connors", "Rivers", "Wilson", "Duncan"]
g = [94, 82, 87, 78, 65,
90, 85, 97, 70, 100,
57, 88, 73, 92, 84]
s.sort()
for i in range(15):
idx = int(i)
studentList = s[idx]
gradeList = g[idx]
print(studentList, gradeList)
print("")
print("Student five: ", s[4], g[4])
print("Student ten: ", s[9], g[9])
print("Student fifteen: ", s[14], g[14])
gradeAverage = (g[0] + g[1] + g[2] + g[3] + g[4] + g[5] + g[6] + g[7] + g[8]
+ g[9] + g[10] + g[11] + g[12] + g[13] + g[14]) / 15
print("")
print("The average of the list of the grades is: ", gradeAverage)
print("The median of the list of grades is: ", g[7])
print("")
def byRank():
studentFound = False
index = 0
searchValue = input("Student to be found: ")
while(studentFound == False) & (index <= len(s) - 1):
if s[index] == searchValue:
studentFound == True
print("Name", searchValue, "was found at index", index)
else:
index = index + 1
print("Name not found. Searching...")
print("Name is not in the array.")
byRank()