Python, Answer not splitting right -


i have little software made python language. behavior:

  1. starts
  2. choose random number 1 100
  3. ask me input try.
  4. it output messsage:

    • 4.1 print number of tries you've done
    • 4.2 print entries of user.
    • 4.3 ask replay again

the problem within section 4.2 print of input of user displayed this

vos essais: 33 44556677798082848687887079747271 

instead of

vos essais: 33 44 55 66 77 79 80 82 84 86 87 88 70 79 74 72 71 

i have tried make works space im trying add separate each characters of print. ( ive join join(). split()) nothing seems works fine.

i know full code not professionnal, i'm beginner.

        liste = tentative         in str(liste):             total = total +             message = total     print("bravo vous avez devinez mon choix après", "\x1b[0;33;40m" + str(compteur) + "\x1b[0m",\ "\x1b[0;33;40m"+ "essais!" + "\x1b[0m", "\nvos essais:", str(premieressaie), str(message)) 

your problem in section of code:

    liste = tentative     in str(liste):         total = total +         message = total 

you iterating through each letter of last guess , adding each digit. should add space well. instead, this:

message += str(tentative) + ' ' 

however, that's not pythonic way solve problem. better keep track of of guesses. then, when print out, can join them string. this:

guesses.append(str(tentative)) 

and when want print out list, this:

print ' '.join(guesses) 

Comments