Skip to content

Instantly share code, notes, and snippets.

@Kwisses
Last active March 9, 2016 01:39
Show Gist options
  • Save Kwisses/1147f9e3b12f386acfd8 to your computer and use it in GitHub Desktop.
Save Kwisses/1147f9e3b12f386acfd8 to your computer and use it in GitHub Desktop.
[Daily Challenge #1 - Easy] - Information Return - r/DailyProgrammer
# ***** DAILY CHALLENGE #1 - Easy *****
# Create a program that will ask the users name, age, and Reddit username. have it tell them the information back,
# In the format:
#
# your name is (blank), you are (blank) years old, and your username is (blank)
#
# for extra credit, have the program log this information in a file to be accessed later.
# ---------------------------------------------------------------------------------------------------------------------
def information(name, age, username):
"""Echos information back to the user.
Args:
name (str): Name of user.
age (str): Age of user.
username (str): Username of user.
Return:
str: Contains information about the user.
"""
result = "Your name is %s, you are %s years old, and your username is %s" % (name, age, username)
my_file.write(str(result) + "\n")
return result
my_file = open("Challenge_1_easy_save", "r+")
n = input("Name: ")
a = input("Age: ")
user = input("Username: ")
output = information(n, a, user)
my_file.close()
print(output)
Your name is John, you are 22 years old, and your username is Kwistech
@Kwisses
Copy link
Author

Kwisses commented Mar 2, 2016

[Daily Challenge #1 - Easy] from the DailyProgrammer subreddit. As a bonus, the code writes the users input to a .txt file.

Reference: https://www.reddit.com/r/dailyprogrammer/comments/pih8x/easy_challenge_1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment