How to Convert a Python String to an Int and an Int to a String?

Rate this post

String β†’ Integer:

s = "42"
i = int(s)
# i == 42

Integer β†’ String:

i = 42
s = str(i)
# s == "42"

Leave a Comment