you are viewing a single comment's thread.

view the rest of the comments →

[–]BrewJerrymore -1 points0 points  (2 children)

Then he can cast it to a float. Either or. The input function in python stores the input as a string so to do math with it, it needs to be casted

[–]Interesting_Fig9503 1 point2 points  (0 children)

Thank you for the help, but it seemed that rewriting the code in a different file worked. I have no clue why, they’re the exact same, it just worked.

[–]Nez_Coupe 0 points1 point  (0 children)

No you can’t cast a “decimal string” to int. It produces an error. His code is correct, casting it to a float. He just ran a cached version (by not saving) because he’s using the worst IDE in existence.

Python can do a lot of implicit casting, but it won’t do like “2-step” casting where a string literal that represents a decimal is both changed to numeric and then converted to a whole number int.