0
How to convert type of variable in Python?
This code did not work:( number=input() print('number to be tested: '+number) int(number) if number>5: result=' is greater than 5' else: result=' is less than 5' str(number) print(number+result)
6 Answers
+ 2
number = int(number) and number = str(number) should do the trick.
+ 1
Input returns a string turn it into an int:
number = int(input())
+ 1
which is the best programing language to learn?
0
Also use the format method to print variable values...
print("Number to test: {}".format(number)) instead of print("Number to test: " + number)
print("{} {}".format(number, result)) instead of print(number + result)
0
depends on what you want to do
0
emm, what if the number receives text instead of real numbers?