How to get the program to quit after user enters 12 or more credits.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • scott dieken
    New Member
    • Sep 2010
    • 5

    How to get the program to quit after user enters 12 or more credits.

    I need to accomplish this with indentation only.



    Code:
    major = raw_input("Enter your major: ")
    major = major.strip().capitalize()
    if (major =="Cent"):
        print "That's my major too"
    else: 
        print major,"is a good major."
    ans = input ("Enter the number of credits you are taking: ") 
    if (ans > 11):
        print "That's a lot of credits."
    else:
        working = raw_input("Are you working? y or n: ")
        working = working.strip().lower()
        if (working == "y"):
            print "Working and going to school is hard"
        else:
            print "It's nice to just be able to study"
    Last edited by bvdet; Sep 15 '10, 10:24 PM. Reason: Please use code tags! [code]...... code goes here ....[/code]
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Is there more code than what you posted? Your indentation was wrong. Please use code tags when posting code.

    Comment

    • scott dieken
      New Member
      • Sep 2010
      • 5

      #3
      no that is the end of the code

      sorry about the tags.
      can you tell me how to fix the indentation so the program works as indicated in the title of the question?

      Comment

      • bvdet
        Recognized Expert Specialist
        • Oct 2006
        • 2851

        #4
        I fixed your indentation, I think. It does quit after the user enters 12 or more. It also quits after the user enters less than 12. Can you be more specific? Do you want the script to loop? If so, you could use a while loop so the loop continues until a condition is met, then issue the break statement.

        Comment

        • scott dieken
          New Member
          • Sep 2010
          • 5

          #5
          Great!
          that's what I needed.
          Thanks

          Comment

          Working...