samedi 17 décembre 2022

How to get an item in a list based on a number in Python? [closed]

I am trying to code something in Python that makes the user type random phrases. If you manage to find out how to do this, I would appreciate it.

import pyautogui
import random

phrases = ["Phrase1", "Phrase2", "Phrase3"]

while True:
    pyautogui.write(list.index(phrases, random.randint(1, len(phrases))))

I was expecting to run the code and be able to type a random phrase (e.g. running the code and either typing "Phrase1", "Phrase2", "Phrase3")




Aucun commentaire:

Enregistrer un commentaire