Turn Messy Text into Structured Insights With AI. Join Greg Live:Β Dec 4th, 2024
Leverage
Glossary

Int

Python data types: int vs. string

Within Python, there are different data types. Think of data types like different formats within Excel. The int or integer is a round number without a decimal point. Python Int is similar to float, but floats have decimal points.

x = 5
print (type(x))
>>> <class 'int'>

Python Int: Be Careful

One thing to be careful of are datatypes that look like an int, but aren’t. For Example, if x = '5' you might think that x is an integer, but because it is encased in quotes, it’s actually a string. This will cause unexpected results or even errors.

Link to code

On this page