-2

I have the following code that prints the 3 words in the list over and over again. I'm trying to figure out how to print one word from the list, then wait for user intervention (like a key press) then print the second word and so on. I think it is probably an easy solution, but I just can't seem to figure it out at this time. I'm new at this. Thanks in advance.

list = ["foo","bar", "baz"]

i = 0

while i < len(list):
    element = list [i]
    i += 1
    print(element)
    if i == 3:
        i = 0
Kripke
  • 1
  • 2

1 Answers1

0

This will do what you're asking as Dan mentioned in his comment:

list = ["foo","bar", "baz"]

i = 0

while i < len(list):
    element = list [i]
    i += 1
    print(element)
    x = input()
    if i == 3:
        i = 0

The line x = input() makes it so that the user has to press enter before the system will print the next element.

gaw89
  • 1,018
  • 9
  • 19
  • sorry about that. I had tried input("press Enter to continue..."), but had it in the wrong spot. – Kripke Jun 14 '18 at 17:40