Python Forum

Full Version: Print next dataset on list when user hits any key
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need with this code. After I read the text file, how do I print one record of the data set at a time and moves to the next record on the list when you hit any key?

# reading dataset
fs = open('data_set.txt', 'r')
lines = fs.readlines()
for line in lines:
    print(line)

fs.close()
This code print out the all the lines on the list, I just want to print one line at a time and wait for the user to press a key before moving onto the next record.

I'm tempted to add:
input("Press any key to continue")
I want this program to run in any system but I'm using a MAC.

Thanks
add an input statement after print with same indentation
(Apr-30-2018, 10:16 PM)Larz60+ Wrote: [ -> ]add an input statement after print with same indentation


Thank you Larz60! I need to make sure I read up on the importance of indentation