Is it possible to use the random module to extract strings from a list, but only if the string has a length greater than x?
For example:
list_of_strings = ['Hello', 'Hello1' 'Hello2']
If you set x = 5 and call random.choice() the code would be 'choosing' between only list_of_strings[1] and list_of_strings[2].
I realise you could make a second list which contains only values of len > x but i would like to know if it is possible without this step.
Aucun commentaire:
Enregistrer un commentaire