How to Construct an Integer From Different Literals in Python


In this example we will show how to construct an integer number from an integer literal, a float literal, or a string literal in Python.

Source Code

a = int(6)     # a will be 6
print(a)

b = int(6.6)   # b will be 6
print(b)

c = int('6')   # c will be 6
print(c)

Output:

6
6
6
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments