Mysterious Printing Errors


https://youtu.be/uyYPihp1DfA

print(5+5)

Prints 10

print("5"+5)

Gives the following error:

Can't convert 'int' object to str implicitly

and strangely the order matters

print(5+"5")

unsupported operand type(s) for +: 'int' and 'str'

Exactly why they are different in the way that they are is not what's important right now. What's important is that you're trying to combine different types and python doesn't know how to do that without help.

Brief List of Python Types

int - whole numbers for counting

float - decimal point numbers

str - strings of text

bool - boolean True or False

There are more but this short list will get you started.

Next Post; String Delimiters

Recent Posts
Tags

© 2019 BrainStemSchool.com