0

I cant seem to get to turn the strings into an integer for a simple calculator

number_1 = input(56) number_2 = input(45) func = add if func == add: print (number_1 + number_2 ) It is something like this

25th Aug 2021, 3:46 PM
The Agamer
3 ответов
+ 5
Please tag the relevant programming language. In Python you can use int() to convert to integer. What is "add" in your example?
25th Aug 2021, 3:51 PM
Lisa
Lisa - avatar
+ 3
You should take a(nother) look at the section about functions in the Python Beginner course. In particular the part about creating your own functions.
25th Aug 2021, 3:58 PM
Simon Sauter
Simon Sauter - avatar
+ 3
if you want to add 2 input without using function, correct your code like that👇 1. number_1 =56 number_2=45 print (number_1 +number_2) 2.if you want to get data from user... without using function number_1 =int(input()) number_2=int(input()) print (number_1 +number_2) 3.If you want to use function def add(n1,n2): return n1+n2 num1=int(input()) num2=int (input()) print("sum is:" ,add (num1,num2)) #hope this helps
25th Aug 2021, 4:53 PM
Myo Thuzar
Myo Thuzar - avatar