Skip to content

Instantly share code, notes, and snippets.

@MattSegal
Created July 20, 2017 04:28
Show Gist options
  • Save MattSegal/3a712d821e7544796700b57b0db2f789 to your computer and use it in GitHub Desktop.
Save MattSegal/3a712d821e7544796700b57b0db2f789 to your computer and use it in GitHub Desktop.
# This works fine
print("hey " + "you!")
# This causes an error because "hey" is a string and 1 is an integer
print("hey " + 1)
foo = "hey " + 1 # This is an error too
print(foo)
# This works fine - the argument is an integer
print(1)
# also works fine - the argument is a string
print ("1")
# Here we convert the integer 1 to the string "1" - no error
print("hey " + str(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment