# hi guys, i really need ur help in python with my homework, please :<

+1 vote
asked Apr 5, 2020
Write a program that calculates the sum of three numbers entered as a character string. All numbers are integers.
Example:
Enter the expression:
12+3+45

–1 vote
answered Apr 6, 2020 by (180 points)
# Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
num3 = input('Enter third number :')
# Add three numbers
sum = float(num1) + float(num2) +float(num3)

# Display the sum
print('The sum of {0},{1} {2} is {3}'.format(num1, num2, num3, sum))
+1 vote
answered Apr 6, 2020 by (180 points)
a=input()
b=input()
c=input()

print("Sum of a ,b and c is",int(a)+int(b)+int(c))
answered Apr 8, 2020 by (220 points)
Hello there. You can use eval() function for your question.

expression = "12+3+45"
print(eval(expression))

Output: 60.
commented Apr 9, 2020 by (130 points)
thanks a lot!
answered Apr 17, 2020 by (160 points)

num = input("Enter the expression : \n")

output:

Enter the expression :
12+3+45

answered Apr 24, 2020 by (140 points)
I know the "eval" function is made for this, but I'm guessing you're supposed to find the solution yourself, not already made.

What about (Python3.x) :

line = input().split('+')
try:
numbers = [int(n) for n in line]
except ValueError:
print("Invalid line format.")
exit(1)
else:
result = sum(numbers)
print(result)