By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,931 Members | 2,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,931 IT Pros & Developers. It's quick & easy.

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

P: 5
I need to accomplish this with indentation only.



Expand|Select|Wrap|Line Numbers
  1. major = raw_input("Enter your major: ")
  2. major = major.strip().capitalize()
  3. if (major =="Cent"):
  4.     print "That's my major too"
  5. else: 
  6.     print major,"is a good major."
  7. ans = input ("Enter the number of credits you are taking: ") 
  8. if (ans > 11):
  9.     print "That's a lot of credits."
  10. else:
  11.     working = raw_input("Are you working? y or n: ")
  12.     working = working.strip().lower()
  13.     if (working == "y"):
  14.         print "Working and going to school is hard"
  15.     else:
  16.         print "It's nice to just be able to study"
Sep 15 '10 #1
Share this Question
Share on Google+
4 Replies


bvdet
Expert Mod 2.5K+
P: 2,851
Is there more code than what you posted? Your indentation was wrong. Please use code tags when posting code.
Sep 15 '10 #2

P: 5
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?
Sep 15 '10 #3

bvdet
Expert Mod 2.5K+
P: 2,851
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.
Sep 15 '10 #4

P: 5
Great!
that's what I needed.
Thanks
Sep 16 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.