dimanche 30 juillet 2017

Can someone tell me what is wrong with this code?

I am trying to get this to work but to no avail, can someone help?

number = 0

statement = "i will go there",number,"times"

for number in statement:
    if number < 5:
    print (statement)
number += 1

What i am trying to do here is to build a general statement first (I will go there number times). I want to change the 'number' inside this statement to 0,1,2,3,4,5 and eventually it prints: i will go there 0 times i will go there 1 times i will go there 2 times i will go there 3 times i will go there 4 times i will go there 5 times But i am getting an error code of:

TypeError: '<' not supported between instances of 'str' and 'int'

Aucun commentaire:

Enregistrer un commentaire