While-Loop Use in Python -


when come 2nd while loop while x == 2: it's still repeating whole script though x /= 1 (not if "n"is entered). let enter "y" on prompt "is correct?" shouldn't x become 3 stops both first , 2nd loop?

this obvious i'm pretty new.

 # -*- coding: utf-8 -*- import time  x = 1 while x == 1:     print "what's name?"     name = raw_input("name: ")     print "how old you?"     age = raw_input("age: ")      print "so %r years old , name %r. correct?" % (age, name)     correct = raw_input("(y/n): ")      while x == 2:         if correct == "y":             x = 3          # x = 3 skips whiles, not working             time.sleep(1)          elif correct == "n":                 time.sleep(1)              x = 1         # x = 1 --> 1st while still in action          else:             print "invalid input \n\t loading..."                x = 2         # x = 2 --> 2nd while takes on  print "where live?"  time.sleep(0.5) country = raw_input("country: ") time.sleep(0.5) city = raw_input("city: ") time.sleep(1)  print " \n data: \n\t name: %r \n \t age: %r \n \t country: %r \n \t  city: %r " % (name, age, country, city ) 

in code never change value of x 2 inner loop while x==2: never runs , loop infinitely. need change value of x inside while x==1: loop enter second loop.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -