Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

0
Still very new. What's the best way to use a input variable in multiple functions?
Post Flair (click to view more posts with a particular flair)
Post Body

Excuse my ignorance, I have absolutely no experience. How can I use a input variable (Such as user_age) in mutiple functions? Should I use a global variable. Appreciate any help

def main():
print('Hi! My name is Rover, what's your name?')
name = input('')
print('\\nPlease to meet you', name   '!')
print('\\nWell '   name   ' I'm from Mars! Where are you from?')
home = input('')
print('\\nWow! '   home   ' sounds so cool!')
print('\\nWhat's your age',name  '?')
calcMartinAge()
calcFare()

def usr_age():
user_age = int(input(''))
return user_age

def calcMartinAge():
MARTIAN_TIME = 1.88
Martian_age = str(int(usr_age() / MARTIAN_TIME))
print('\\nWOW! On Mars you'd only be '   Martian_age   '!')
return Martian_age

def calcFare(usr_age):
if usr_age \> 19 and usr_age \< 65:
print('\\nYa know your fare to Mars would only be $10,000!')
elif usr_age \< 12:
print('\\nYa know your fare to Mars would only be         $5,000!')
else:
print('\\nYa know your fare to Mars would only be $7,000!')

main()

Author
Account Strength
70%
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
2,967
Link Karma
2,144
Comment Karma
790
Profile updated: 4 hours ago
Posts updated: 9 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago