I have a code which prints the rows which are in SQL database. What I need is to know if they were printed. For example what I have in my code is simple print, but I'm trying to do also add an input("Enter anything to continue")
And for it to work I somehow have to make the if statement? In my code I added continue
, but that gives me error and I can't return to my menu when entering anything in input function. If I would add these inputs to continue in for rows in adminu_data:
They would not work how they should. For example when one row is printed the time.sleep(5)
and other lines works.
finally:
#closing database connection.
if(connection):
cursor.close()
connection.close()
print ("ID, NUMBER, APP-LAUNCH-TIME, REGISTERD-TIME")
for rows in adminu_data:
print ("Registered. ",rows)
time.sleep(5)
input("\n* Enter anything to continue... ")
os.system('cls')
input("Enter anything to return to main menu")
continue
EDIT **
For those who don't understand is what I'm trying to do is: When the lines were printed with for rows in adminu_data:
, I need to make a simple input("press enter to continue")
, but the problem is that the print function prints multiple lines, after printing one line this code would launch it I would add it input("press enter to continue")
. So what I need to do is after completed printing lines, launch the input code.
If you just want to wait for the user input after printing everything just delete the first input:
def main():
adminu_data = ["one", "two", "three", "four"]
print ("ID, NUMBER, APP-LAUNCH-TIME, REGISTERD-TIME")
for rows in adminu_data:
print ("Registered. ",rows)
input("Enter anything to continue")
You might want to provide a sample of your data if theres still something wrong.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.