Dynamic Data type assignment

sushma ms sush0907 at gmail.com
Tue Jan 28 07:03:00 EST 2020


Hi

Please find below example and the compiler error,

when i'm assigning value dynamically and when we comparing in "if" loop it
is throwing compiler error. It should not throw error it should assign and
act as int why it is thinking as string.

*Code Snippet:*
print("Hello World")

num = input("Enter number ")

print(num)

if(num%3 == 0):
    num+=num
    print(num)

*Output in Console:*
Hello World
Enter number 15
15
Traceback (most recent call last):
    File "main.py", line 15, in <module>
       if(num%3 == 0):
TypeError: not all arguments converted during string formatting
Created the issue:
msg 360865 created
issue 39476 created
-- 
Thanks & Regards,
---------------------------------
Sushma
Mob:9740055884


More information about the Python-list mailing list