0
In simple calculator code at point where two userinput no are being added and stored in result 'str' is added before (a+b).WHY?
in the control structure lesson,in the simple calculator program, where the two user inputs are being added the code is ( elif user_input == "add": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 + num2) print("The answer is " + result) why is there str in result = str(num1 + num2) what is the reason?
2 Answers
+ 7
cause u r converting floats to string so u can add the string "the answer is" + result, u can do that without the str too like this result = num1+num2
print("The answer is", result) with a , instead of +
0
thank you so much