-2
I have a problem and I’m looking for the best way to solve it.
I have a function that inserts in an array 26 positions starting from the letter 'to' down to the last letter of the alphabet which is the letter 'z' : Ex:
import random
def caractere_array():
caractere = []
for i in range(26):
caractere.append(chr(65+i))
def novocaractere_array():
novocaractere = [65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 ]
incluir = random.randrange(0,200)
for i in [chr(65+i)]:
#valores a colocar o mesmo incluir
try:
novocaractere[novocaractere.index(i)] = incluir
except:
pass
I thought it would do 'to' n times
I’d like to repeat the character 'to' 26 times using the python range resource. Any idea how to do something like this?
If the list should contain only the letter
a
, why did you dochr(65+i)
?– Woss
Wow this would not do up to n? Example, a, a ... being char(65 till n times)?
– user164400
You know what the function
chr
ago?– Woss
The Chr() function returns the character corresponding to the numeric code passed as parameter.
– user164400
Be careful when editing the question. An issue only serves to correct problems present in the question or improve it, never to change it and ask new questions. If you have any doubt that was not addressed in the original question you should create a new one.
– Woss