Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

why it is showing str type even after typecasting?

Code:

a,b = input("enter two values").split(",")
int(a)
int(b)
print(type(a))
print(type(b))

Output

enter two values 13 ,14
13 ,14
<class 'string'>
<class 'string'>

>Solution :

The int operation returns a new value, it doesn’t change the type of the variable you pass to it. You’re not reassigning the original variables, so those values don’t change types.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Try this:

a,b = input("enter two values").split(",")
a = int(a)
b = int(b)
print(type(a))
print(type(b))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading