Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

My Python project where i used return keyword

hello everyone creig was teaching return keyword in python basics so i thought to build one calculator plz everyone can someone help me to reduce the code a little bit more this was my first project in python basics i am very happy i build it on my own

def add(first,second):
    answer = first + second
    return answer

def subtract(first,second):
    answer = first - second
    return answer

def multiply(first,second):
    answer = first * second
    return answer

def divide(first,second):
    answer = first // second
    return answer

def solve(way):
    first = int(input("Type ur first number? "))
    second = int(input("Type ur second number? "))
    x = way(first,second)
    return x


print("1 = Addition")
print("2 = Subtraction") 
print("3 = Multiplication")
print("4 = Division")
question = int(input("What u wanna do? "))

if question == 1:
    addition = solve(add)
    print("Your Answer is {}".format(addition))
elif question == 2:
    subtraction = solve(subtract)
    print("Your Answer is {}".format(subtraction))
elif question == 3:
    multiplication = solve(multiply)
    print("Your Answer is {}".format(multiplication))
elif question == 4:
    division = solve(divide)
    print("Your Answer is {}".format(division)) 

[MOD: added ```python formatting -cf]