So I'm pretty much a newbie at coding in python. We have a problem that we were asked to solve, so my problem is whenever I input a value and the while loop ends the lastest input is the only one that gets displayed. Additionally I try to set a limit on the number of inputs however what my code prints out is more than what I set for example the limit = 2 however the values printed will be 8? How do I solve this? Thanks!
p.s yes i'm trying to represent it within a table
This is my code for example!
amongus = []
entries = 2
while entries > 0: # We will decrement max_tries on each loop
#User Inputs
if entries==0:
break
mat1 = input ("Input the Book Name: ")
amongus.append(mat1)
mat2 = input ("Input the Author: ")
amongus.append(mat2)
mat3 = input("Input the Dewey Decimal Number: ")
amongus.append(mat3)
mat4 = input ("Input the Book Shelf Number: ")
amongus.append(mat4)
entries -= 1
#Printing Details
print("| Title"," "*25,"| Author"," "*8,"| Dewey Decimal"," | Bookshelf"," ")
print("-"*82)
for element in amongus:
print("|",mat1," "*(55-len(mat1)),"|",mat2," "*(60-
len(mat2)),"|",mat3," "* (17-len(str(mat3))),"|",mat4," "*(10-len(mat4)))
print("-"*82)