This doesn't refer to any particular problem set. I'm simply trying to convert the data type from str to int. Using the online tutorials this shouldn't be a problem, but I just cannot see me error.
Here's what I typed into the Python Shell:
IDLE 1.2.4
>>> data_type_conversion = '7'
>>> type(data_type_conversion)
your variable "data_type_conversion" is still pointing to the string '7'. to change it to point to integer 7 you need to reassign it so...data_type_conversion=int(data_type_conversion)
Thanks! I mistakenly thought typing "int(data_type_conversion)" handled the new assignment. I'll remember to use the proper assignment next time.
the interpreter can make things kind of confusing because it immediately displays the value for the function you use, making it easy to think that it has assigned it to the variable. I've made the same mistake before lol another tricky thing is that multiplying string will still work, so for instance, if you multiplied by 2 the result would be '77' not 14, which might be hard to debug in a program since it won't give you an error.
Join our real-time social learning platform and learn together with your friends!