1

def main():

print ('Please Enter an integer')

print ("")

integer = input()    

print ('you have entered ' + integer)

print ('Twice of that number is ' + integer * 2)

i need the input to multiply by 2, but when i run it, the final line says "twice of that number is 4242" when i input 42 as the integer, instead of 84

Isaac Barr
  • 19
  • 1
  • 1
    You need to convert your integer into a string to print it. So like so: ``` print ('Twice of that number is ' + str(integer * 2)) ``` python doesn't allow for concatenating of integers and strings – Sweet Chilly Philly Feb 09 '20 at 21:59
  • @SweetChillyPhilly: you forgot the first half: `input` returns a string. As OP found out, you can't multiply a string with a number and expect a correct mathematical output. (There are no 2 digits `a` and `b` so that `str(a)+str(b) == str(a+b)` in decimal.) – Jongware Feb 09 '20 at 22:45
  • Simply convert it to an int then: print ('Twice of that number is ' + str(int("2") * 2) – Sweet Chilly Philly Feb 10 '20 at 00:47

0 Answers0