r/learnpython • u/Usual_Mistake • Sep 23 '19
New to python, do I have to force conversion everytime I want to use a variable?
Hey redditors,
I am playing around with python and I want to create a program that determines how long it will take me to save a certain amount, but I notice that I get a typeError even though I have converted everything to float.
Here is the link to the code: calc1.py
1
Upvotes
2
u/VirulentCitrine Sep 23 '19
OP, I'm not getting any errors when I run your code on my end, so perhaps check your editor's settings?
The other user said you should switch your code from:
to
rent = float(input())and that is true, as it is a better practice, but it shouldn't cause you any errors either way.
Also, I just have to say that when I clicked on your third example file, I almost fell off my chair laughing because of how random it was when I read "
I will now count my chickens!" lmao. Not making a joke at you, I just wasn't expecting that.1
u/[deleted] Sep 23 '19
There's like six scripts in this link. Can you be more specific so we don't have to read your mind?
2
u/Phillyclause89 is u/SoNotRedditingAtWork Sep 23 '19
You’re not assigning your converted variables to a namespace. Instead of
Try:
Or: