
November 18th, 2012, 04:25 PM
|
|
Contributing User
|
|
Join Date: Mar 2012
Posts: 33
Time spent in forums: 8 h 25 m 17 sec
Reputation Power: 2
|
|
Quote: | Originally Posted by t3hmobster Hi there i'm pretty new to python and programming in general. I've been trying to teach myself while building this "budget planner program". I'd really appreciate some help figuring this out or maybe just lead me in the right direction to where I can figure it myself with some helpful hints
PHP Code:
conf1 = str(raw_input('Y/N: '))
if conf1 == 'y' or conf1 == 'Y':
print 'Confirmed'
elif conf1 == 'n' or conf1 == 'N':
print 'Not Confirmed'
else:
print 'Please confirm using Y/N please.'
wage_1 = float(raw_input('\nHourly Wage: '))
print 'your hourly wage is', wage_1,'correct?'
conf2 = str(raw_input('Y/N: '))
if conf2 == 'y' or conf2 == 'Y':
print 'Confirmed'
elif conf2 == 'n' or conf2 == 'N':
print 'Not Confirmed'
else:
print 'Please confirm using Y/N please.'
So how can I make this to were if the user enters 'N' or nothing at all it will return to the beginning of the if statements? |
Something like this:
Code:
def a_Function():
# code for if statements
if a == 'y':
print "yes"
elif a == 'n':
a_Function()
this is called Recursion, where a functions calls itself. This is how you would repeat the if statements but its not a good idea to do it in this senario because if a user says no they mean NO
|