KnowledgeBoat Logo

Computer Science

What is the problem with the following code fragment?


a = 3
s = a + 10
a = "New"
q = a / 10

Python Funda

19 Likes

Answer

The statement

a = "New"
converts a to string type from numeric type due to dynamic typing. The statement q = a / 10 is trying to divide a string with a number which is an invalid operation in Python.

Answered By

10 Likes


Related Questions