Python Forum
Script that alternates between 2 text messages
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script that alternates between 2 text messages
#1
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?
Reply
#2
from itertools import cycle
from time import sleep

for msg in cycle(['Drive', 'Through']):
    print(msg)
    sleep(2)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python script that deletes symbols in plain text nzcan 3 703 Sep-05-2023, 04:03 PM
Last Post: deanhystad
  Simple text to binary python script gmills13 2 2,825 Feb-04-2020, 08:44 PM
Last Post: snippsat
  index error in text script Bartry 2 2,459 Dec-09-2019, 11:50 AM
Last Post: Malt
  auto supply values to a python script(function) from text file metro17 4 2,546 Oct-26-2019, 01:25 AM
Last Post: ichabod801
  logging messages ahead of print messages vindo 6 3,214 Jun-18-2019, 02:45 PM
Last Post: vindo
  Problem with sending text file as an attachment using this Gmail OAuth script downloaderfan 6 6,995 Feb-07-2018, 09:54 PM
Last Post: downloaderfan
  Get return text from a failed script jonesin1974 2 4,083 May-12-2017, 10:44 PM
Last Post: jonesin1974
  How to make a script to find a certain word in text files in a whole directory ? RandoomDude 2 5,966 Apr-27-2017, 10:27 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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