0
Why is this code running absolutely fine on Idle but not on Pycharm ?
26 Respostas
+ 11
OK I see. So the exception handling bugs on the Linux pycharm. Strange...
+ 10
'A' can't be converted to float, it's not a number.
+ 10
So a simple code like this:
try: float('a' )
except ValueError: print('error')
Shouldn't work. Can you try this?
+ 10
OK.
I already can give you this advice: pycharm is a very heavy machine. I also had bugs with it. Some of them unsolved. So unless you really need pycharm and its million functionalities, you may be happy and running with 'sublime text 3' (as I do).
+ 10
Look at Flandre Scarlet 's answer.
I missed that. Your code is wrong when' add' case is chosen. And that's where the bug comes from.
+ 10
Oh wait, the first error you posted was with 'div' choice. So there still may be a pycharm bug.
You should correct your script and see if it still bugs then.
+ 10
Difficult to understand what happens here.
I re-installed Pycharm on my linux laptop, so it's the 2019.1 version too.
Then pasted my corrected version of your code in it, and it always works fine.
Your error is a mystery to me.
If you want to work on ide, you can keep on with idle, but i also suggest Geany, it's much lighter than pycharm, and executes your files by launching a terminal.
About SublimeText, its embedded console is limited, and for this code it won't be able to take the successive inputs (which may have been the reason why you uninstalled it). But you can keep a terminal on the side and launch your files from there. Once you get used to this, it's really fine.
+ 9
If you just try :
float("A")
You'll see the same error.
+ 9
I saw your screenshot. But seems to be on windows. Does this work fine on Linux ?
+ 9
I corrected your file.
Look at the changes at line 20
https://code.sololearn.com/cLPNULkOxapi/?ref=app
+ 8
I've just checked it on pycharm community 2018.2 on my windows pc, it works fine.
Your problem may come from your pycharm settings.
+ 8
Well, from the error message you got, it seems you entered 'A' as the second number, which your code tries to turn into a float.
If this is what you typed, then it's normal you get an error.
+ 8
Sure, with adequate numbers, your code will work.
There was a problem with your input, not with your code đ
+ 8
Why you're printing float(a) + float(b) when your inputs are stored in x and y?đ
+ 2
CĂ©pagrave
https://drive.google.com/file/d/1i6CrKmIakLTU5vGQT1YIoCma-N4vAgs7/view?usp=sharing
i uninstalled sublime text 3same day i installed thst on my machine because i faced similar issues. Code was working fine on idle but not on ST3(on linux).
~ swim ~
yeah bro, u r right.
+ 1
CĂ©pagrave, I am getting the following on pycharm 2019.1 community :
*************************WELCOME***************************
ENTER 'ADD' FOR ADDITION.
ENTER 'SUB' FOR SUBTRACTION.
ENTER 'MUL' FOR MULTIPLICATION
ENTER 'DIV' FOR DIVISION.
ENTER 'QUIT' TO END/EXIT THE PROGRAM.
ENTER ANY OF THE OPTIONS : DIV
ENTER A NUMBER : 45
ENTER ANOTHER NUMBER : A
Traceback (most recent call last):
File "/root/PycharmProjects/simple-calculator/calcc.py", line 32, in <module>
y = float(input('ENTER ANOTHER NUMBER : '))
ValueError: could not convert string to float: 'A'
Process finished with exit code 1
+ 1
oh yeah, its also working fine on pycharm running on windows machine.
+ 1
Will try that out later & let u know.
0
Yeah 'A' was the second number