Support Forums

Full Version: So weird
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Quote:I'm trying to learn Python, I installed Python 2.7.3 and for some reason, when I watch "TheNewBoston" video, I typed the same code as him, save as .py, i couldn't double click on the .py file to execute it. I right click and check the filetype is just "file".

For example
x = raw_input("Enter name here: ")
print "Hey " + x
<ok solved it by adding "raw_input("Press<enter>")">

If I use notepad++ to save .py , I can double click, but when I type in the name and press enter, it closes...

hope you understand my problem
thanks.

but is there a differences between python 3 and 2? I tried 3 and some codes for 2 is not working.
There are only very small differences between 3 and 2, and the only one you'll encounter (most likely), as a beginner, is

print('Hello')

working in both,

but print 'hello'

working only in 2.

@Your Problem: To not have to add a print or stop, you should just use idle.
Open idle > file, new window> f5 to execute
Also, when I type this

>>> x = input("Enter number here: ")
Enter number here: 4
>>> x + 1

In 2, it give me 5, but in 3, it gives me error, something about integer and string...
I'm not sure what you're trying to say, but you could try putting:
Code:
x = int(input("Enter your number here: "))



Nevermind, I just realized you were talking about the version of python. Adding int should work, because of the differences between raw_input and input in 2 and 3. The difference is that 3 does not have a raw_input function, input is what raw_input is in 2.
I would recommend staying with version 3. I know version 2 has more tutorials and overall more support, but 3 is way forward and tbh there are only very minor differences that can easily be identified and solved when stumbled upon.