Python Forum

Full Version: Script that alternates between 2 text messages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am completely new tho Python, but i would like to program a script that alternates between 2 text messages.

first is displays "Drive" and then 2sec later "Through", then again 2seconds later "Drive", and so on...

Can somebody help me please?
from itertools import cycle
from time import sleep

for msg in cycle(['Drive', 'Through']):
    print(msg)
    sleep(2)