vendredi 20 août 2021

How to get line number

So I made a random name generator but I want it to even print the line number of the name, So how do I get the line number? Code:

import random

names = open(r"names.txt", "r")
name1 = readlines(names)
name = random.choice(name1)
names.close()

print(name)

So y'all got any ideas?




Aucun commentaire:

Enregistrer un commentaire