why we need to type cast | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

why we need to type cast

15th Sep 2016, 10:59 AM
Akshatha
Akshatha - avatar
2 Réponses
0
Because there is no strict typing in Python (f.e. the same variable may give you an access to integer value, and right after that you may assign it to string). So in Python type of variable depends on type of expression it is assigned to, and we need to make conversion explicitly, to make sure this type is one we need. w = "1" # w is string w = int("1") # w is int
15th Sep 2016, 3:29 PM
Textobot
Textobot - avatar
0
ho k thank u
16th Sep 2016, 5:39 PM
Akshatha
Akshatha - avatar