Reputation: 67
I am using Pycharm 3.4.1 with Python version 3. For two days my basic/simple codes haven't been working. Pycharm says code executed with 0 mistakes. But there are no prints or results in the end.
Can anyone check the codes? Is there anyone who has experienced the same thing?
Code 1:
#Welcome to basic calculator, let's start..
a = int(input("Enter your first number: "))
b = int(input("Enter your second number: "))
type = str(input("Please choose your calculation type: +, -, *, / "))
if type == "+":
print("The result is: ", a + b)
elif type == "-":
print("The result is: ", a - b)
elif type == "*":
print("The result is: ", a * b)
elif type == "/":
print("The result is: ", a / b)
else:
print("The command you entered is not valid")
Code 2:
class Enemy:
life = 3
def attack(self):
print('attack!')
self.life -= 1
def check(self):
if self.life <= 0:
print("I am dead")
else:
print(str(self.life) + " life left")
enemy1 = Enemy()
enemy2 = Enemy()
# each object is independent of one another, they don't share variables
enemy1.attack()
enemy1.attack()
enemy1.check()
enemy2.check()
Upvotes: 5
Views: 17418
Reputation: 41
Had the same problem. In my case the anti-virus software (Comodo) hat the file contained and didn't allow it to access the console.
After setting the file to safe in Comodo the output works fine.
Upvotes: 4
Reputation: 33
I had this exact same problem and I'm also a noob with python and pycharm. I followed the JetBrains debugging tutorial and their sample script ThreadSample.py jumped into the debugger and did everything exactly the way it was supposed to. But then I spent a couple days trying to debug one of my own python scripts, or even get it to run! (Runs perfectly in IDLE.) What finally worked for me was creating a brand new project, copying only that script into it and now Pycharm does everything it's supposed to with it. My working guess was that Pycharm does so much micromanagement with the file system that it got all goobered up when it found my original script in a folder with a bunch of files that didn't have anything to do with python or Pycharm. Anyway, this worked for me.
Upvotes: 1