jeudi 24 novembre 2016

Converting a random item of a list to uppercase [on hold]

I'm trying to convert a random item (line) and save it back into the list so that when I print the whole list it prints the full list but with a random line in uppercase.

Here is what I tried, but it does not work:

import random
lines = ['abc', 'def', 'ghi', 'jkl']
random.choice(lines).upper()
print(lines)

Example of desired output:

abc
def
GHI
jki




Aucun commentaire:

Enregistrer un commentaire