3
I’m trying to make a show where he throws a letter on the screen you press it and supposedly you should get a point so I know this is probably a really stupid question, but I tried it in a lot of ways and I couldn’t.
import random
def main():
x = random.randint(0,25)
ponto = 0
letra = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
rletra = letra[x]
print (rletra)
print ('Sua pontuação é:', ponto)
a = input('')
if a == rletra:
ponto += 1
print ('Sua pontuação é:', ponto)
main()
else:
print('errado')
main()
The only thing that happens is that the point value goes to 1 and does not increase.
Is there any way to adjust the indentation of your code? Otherwise, you can’t know if the code is wrong or it’s a flaw in the indentation.
– fernandosavio
Instead of recursiveness, which doesn’t make much sense in this case, why not a repetition loop?
– Woss
It’s just that I don’t really know how to format code around here, but I think it’s right now
– Guilherme Freitas
@Andersoncarloswoss and how would I do that? using a for?
– Guilherme Freitas
And when should it close? Without a criterion it would never end, this is what you want?
– Maniero
@Maniero ends only when the user misses the letter
– Guilherme Freitas