Casting

From wikieduonline
Revision as of 03:34, 3 March 2022 by Chmod15 (talk | contribs)
Jump to navigation Jump to search

There may be times when you want to specify a type on to a variable. This can be done with casting.

x = str(3)    # x will be '3'
y = int(3)    # y will be 3
z = float(3)  # z will be 3.0

Related

See also

Advertising: