I want to be able to get variables such as dns_float_a that were defined inside the latitude() function object to work outside latitude().
The section of code I'm working with is below. It shows two variable objects defined using def ():. I then want to print the equation at the bottom, but in order to do this I need to reference the variables within the function objects.
PS this is literally the first program I've ever written (it's part of a longer latitude/longitude conversion program) so try don't assume I know much please!
Thanks in advance!
def latitude():
#LATITUDE
print "***Degrees/Minutes/Seconds >>> Decimal Degrees***"
print
print "Input Latitude"
dns_a=raw_input("Degrees: ")
mns_a=raw_input("Minutes: ")
sns_a=raw_input("Seconds: ")
ns=raw_input("North (1) or South (2): ")
dns_float_a=float(dns_a)
mns_float_a=float(mns_a)
sns_float_a=float(sns_a)
ns_float=float(ns)
#south
if ns_float==2:
dns_float_a=dns_float_a*(-1)
mns_float_a=mns_float_a*(-1)
sns_float_a=sns_float_a*(-1)
ns_x="South"
#north
elif ns_float==1:
dns_float_a=dns_float_a*1
mns_float_a=mns_float_a*1
sns_float_a=sns_float_a*1
ns_x="North"
elif ns_float<1 or ns_float>2 or ns_float>1 and ns_float<2:
print
print "*Invalid Input*"
latitude()
def longitude():
#LONGITUDE
print
print "Input Longitude"
dns_b=raw_input("Degrees: ")
mns_b=raw_input("Minutes: ")
sns_b=raw_input("Seconds: ")
ns=raw_input("East (1) or West (2): ")
dns_float_b=float(dns_b)
mns_float_b=float(mns_b)
sns_float_b=float(sns_b)
ns_float=float(ns)
#south
if ns_float==2:
dns_float_b=dns_float_b*(-1)
mns_float_b=mns_float_b*(-1)
sns_float_b=sns_float_b*(-1)
ns_x="South"
#north
elif ns_float==1:
dns_float_b=dns_float_b*1
mns_float_b=mns_float_b*1
sns_float_b=sns_float_b*1
ns_x="North"
elif ns_float<1 or ns_float>2 or ns_float>1 and ns_float<2:
print
print "*Invalid Input*"
longitude()
latitude()
longitude()
#(d/m/s)ns_float_a
decimal_degrees_latitude=(dns_float_a)+(mns_float_a/60)+(sns_float_a/3600)
#(d/m/s)ns_float_b
decimal_degrees_longitude=(dns_float_b)+(mns_float_b/60)+(sns_float_b/3600)
print
print "Results:"
print
print "Latitude: ", decimal_degrees_latitude
print "Longitude: ", decimal_degrees_longitude
print