-1

Today i downloaded my new python 3.8.5 version 32 bit in 64 bit PC and tried a simple addition program. This is my code:

value = input("Please enter a string:\n")
value2 = input("Please enter a string:\n")
value3 = value+value2
print(f'You entered {value+value2}')
print(f'You entered {value3}')

This is the result:

= RESTART: C:\Users\mcheg\AppData\Local\Programs\Python\Python38-32\trial_later delete filie1.py
Please enter a string:
12
Please enter a string:
34
You entered 1234
You entered 1234
wjandrea
  • 23,210
  • 7
  • 49
  • 68
  • I mean, you entered two _strings_ (and you know they're strings!), then concatenated them with `value+value2` and got another string. This is what's supposed to happen – ForceBru Jul 28 '20 at 14:00

2 Answers2

2

You need to convert the inputs to int. By default, input values are string

value = int(input("Please enter a string:\n"))
value2 = int(input("Please enter a string:\n"))
value3 = value+value2
print(f'You entered {value+value2}')
print(f'You entered {value3}')
bigbounty
  • 14,834
  • 4
  • 27
  • 58
0

Since the inputs are strings by default so if you want integers you need to convert as done below :

value1 = int(input("Please enter a string:\n"))
value2 = int(input("Please enter a string:\n"))
Utk
  • 1
  • 2