I am trying to create a simple Python script using v3.8 to do the following:
- Create 2 seperate lists
- Have the lists grow based off user input (you exit by not entering an integer)
- Display the lists vertically side by side
Individually, I have all the items working. When I add my for
loop, which comes after my try
block, the script shuts down. If I put the for
loop before my try
block it works fine, which tells me it's coming from my try
block. However, no matter how many times I try to google the answer and try different methods I just can't figure it out.
Code:
nameList = []
countList = []
try:
while True:
nameList.append(str(input("Enter Name: ")))
countList.append(int(input("Enter Count: ")))
except Exception:
pass
print("Name" '\t' "Count")
for o in range(len(nameList)):
print(nameList[o] + '\t ' + countList[o])
sleep(2)