5*2=55 not 10! Why?

Question:

I want to output 5 * 2 = 10 but python output is 55!
How do I resolve this problem?

a = 0
b = 2

a = input("a? :") #(get 5 as input)

c = a * b

print (c)

This is my code.
when I input a number it repeat same number I entered two times insterd of showing multipiy it. What do I have to do to solve this?

Asked By: Tharindu Thathsara

||

Answers:

I am not familiar with python, Are you making it into a string?
In dart if you multiply a number by a string it will print the string as many times as you multiply.
I.e.
"5" * 2 = "5""5", displayed as 55
Is it possible that you are doing this?

Answered By: George Lee

a is a string,

so it will be

'5'*2='55'

if you want 10, you need to cast a to int.

a=int(input())

here is the link to document

https://docs.python.org/3/library/functions.html#input

Answered By: Talha Tayyab
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.