I'm making a text converter, and I'd like to select random characters in a string that already exists.
When I research it, all that comes up is someone that wants to generate random letters in the alphabet or someone that wants to generate a random string. That's not what I'm looking for.
new_string = ""
index = 0
for letter in input_text:
if letter not in "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM":
new_string = new_string + (letter)
continue
index += 1
if index % 2 == 0:
new_string = new_string + (letter.upper())
else:
new_string = new_string + (letter.lower())
My existing text converter capitalizes every other letter, but I'd like to have it randomly capitalize the letters. Is this possible?
Aucun commentaire:
Enregistrer un commentaire