python len int code example
Example 1: python execute string
a = """
A = 5
if A > 0 :
print("A Is Positive")
elif A == 0 :
print("A Is Equal To 0")
else :
print("A Is Negative")
"""
exec(a)
>>> A Is Positive
#you can also use eval(string) for asyncio
Example 2: python input integer
# To prompt the user to input an integer we do the following:
valid = False
while not valid: #loop until the user enters a valid int
try:
x = int(input('Enter an integer: '))
valid = True #if this point is reached, x is a valid int
except ValueError:
print('Please only input digits')
Example 3: len of int python
len(str(n)) #n is a number