Python Forum
Print next dataset on list when user hits any key
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print next dataset on list when user hits any key
#1
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
Reply
#2
add an input statement after print with same indentation
Reply
#3
(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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 12 571 Apr-12-2024, 11:51 AM
Last Post: deanhystad
  How do you get Python to print just one value in a list? 357mag 3 1,001 May-17-2023, 09:52 PM
Last Post: rob101
  user input values into list of lists tauros73 3 1,062 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  functional LEDs in an array or list? // RPi user Doczu 5 1,582 Aug-23-2022, 05:37 PM
Last Post: Yoriz
  Print List to Terminal DaveG 2 1,427 Apr-02-2022, 11:25 AM
Last Post: perfringo
  Looking for a way to loop until user enters from a list? PythonW19 7 3,328 Mar-21-2021, 08:56 PM
Last Post: PythonW19
  User input/picking from a list AnunnakiKungFu 2 2,316 Feb-27-2021, 12:10 AM
Last Post: BashBedlam
Question Reset list if user regrets Gilush 1 2,064 Dec-05-2020, 10:55 AM
Last Post: Gilush
  Print max numbers in a list jimmoriarty 1 2,144 Sep-25-2020, 07:29 AM
Last Post: DPaul
  Print variable values from a list of variables xnightwingx 3 2,614 Sep-01-2020, 02:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020