Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Tip: Python Variables and Typing

DZone's Guide to

Tip: Python Variables and Typing

· Web Dev Zone
Free Resource

Learn how to build modern digital experience apps with Crafter CMS. Download this eBook now. Brought to you in partnership with Crafter Software

Never forget, Python uses duck typing and has typed objects but untyped variable names.

lfc = "Liverpool" # this is a string
manc = "Manchester City"
l_score = 3 # this is a integer
m_score = 0
print "Result",lfc,l_score,"-",m_score,manc
Result Liverpool 1 - 0 Manchester City

How to know the type of variables:

type(lfc)
<type 'str'="">
type(l_score)
<type 'int'="">

Source:  http://glowingpython.blogspot.com/2011/04/variables-and-typing.html


Crafter is a modern CMS platform for building modern websites and content-rich digital experiences. Download this eBook now. Brought to you in partnership with Crafter Software.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}