I want pyautogui to type days in a month from 1 to 31. Bellow each number I want it to type city name from an array. Problem is that when loop finishes, in the next run it has a chance to print the same city which I don't want. It can and should print it again just not twice in a row.
I tried several options I was able to Google but none worked. Here's my code. If you have suggestions on how to fix it or completely new code please let me know.
import pyautogui, random
dayDate = 1
while dayDate < 32:
pyautogui.click(380, 325)
pyautogui.typewrite(str(dayDate))
pyautogui.click(380, 345)
cities = ['London', 'Paris', 'Berlin', 'Barcelona', 'Moscow']
city = random.choice(cities)
print(city)
pyautogui.typewrite(str(city))
dayDate += 1
Just that I'm clear, preferable output in terminal should not have same city twice in a row.
Eg:
-
London 2. Berlin 3. Berlin 4. Moscow - wrong
-
Berlin 2. London 3. Berlin 4. Moscow - correct
Aucun commentaire:
Enregistrer un commentaire