#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    How do you try a code again


    print "Math program"
    a = input ("1 + 5 = ")
    if a == "6":
    b = input ("7 + 3")
    else:
    if b == "10":
    c = input ("11 + 11")
    else:
    if c == "22":
    d = input ("22 + 1")
    else:
    if d == "23":
    e = input ("12 + 5")
    else:
    if e == "17":
    f = input ("20 + 8")
    else:
    if f == "28":
    g = input ("7 + 9")
    else:
    if g == "16":
    h = input ("2 + 30")
    else:
    if h == "32":
    i = input ("7 + 45")
    else:
    if i == "52":
    j = input ("22 + 50")
    else:
    if j == "72":
    os.startfile("a2.bat")
    else:



    I tried this code but now i want to make it reapeat the preseadure it did but i cant give an exact preseadure to take because at the end the all lead to one else
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,854
    Rep Power
    481
    I think you do it more like this.
    Code:
    import random
    while True:
        a = random.randrange(100)
        b = random.randrange(100)
        c = int(input('%d + %d = ? '%(a,b)))
        if c == a+b:
            break
    I couldn't think of a reasonable way to indent your program.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo