Dynamic Data type assignment

Rhodri James rhodri at kynesim.co.uk
Tue Jan 28 12:16:28 EST 2020


On 28/01/2020 12:03, sushma ms wrote:
> 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 absolutely should throw an error.

> it should assign and
> act as int why it is thinking as string.

Because it is a string.  The documentation of "input" is quite explicit 
about this:

  input([prompt])

     If the prompt argument is present, it is written to standard output 
without a trailing newline. The function then reads a line from input, 
converts it to a string (stripping a trailing newline), and returns 
that. When EOF is read, EOFError is raised.


-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-list mailing list