Ask coding questions

← Back to all posts
why wont this work
EthanHarris5 (0)

num = int(input("Enter a number:"))
if(num > 0 ):
print (num "is positive")
elif(num < 0 ):
print (num "is neagtive")
print(num"= 0")

ash15khng (656)

The code you uploaded in the repl works, but the one you typed out doesn't, because to concatenate strings together you need to use a + sign. Example:

"Hello" + "World" # this becomes the string "HelloWorld"
123 + "World" # this gives an error
str(123) + "World # this becomes 123World

You can only concatenate strings together.