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

String β†’ Integer:

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

Integer β†’ String:

β™₯️ Info: Are you AI curious but you still have to create real impactful projects? Join our official AI builder club on Skool (only $5): SHIP! - One Project Per Month

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

Leave a Comment