Hello, i'm new to python, I mostly program in C++. i'm adding values, but it doesn't give me the right answer.

x = input("Enter number: ");
y = input("Enter a another number: ");
z = x + y;

print("Answer is: " + z);

if i enter 5 + 5 it gives me 55, which isn't right. i tried converting the values to int()
but it gives me a syntax error.

Recommended Answers

All 3 Replies

Yes convert the number to int or float and do not add result to string.

can you show me how? i still keep getting an error.

Most of the online tutorials cover input and conversion from on data type to another.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.