hello there, i started learning python yesterday and im having quite a bit of difficulty following tutorials...
I was following this tutorial
but most of what i wrote did not work. How do i make the code compatible with python 3.0?.
for instance it says
lucky=7
print lucky
but when i do this, it says "invalid syntax"
but if i simply type lucky and press enter it works???:confused:
and here's another...
changing = 3
print changing
changing = 9
print changing
different = 12
print different
print changing
changing = 15
print changing
also what is the difference between the single quotes double
quotes when declaring strings?:-/
-----------------------------------
outputs...
>>> if 1: print ("true")
print ("done")
SyntaxError: invalid syntax (<pyshell#1>, line 2)
>>> print ("hello world!")
hello world!
>>> print ("hello world!"),
print ("who the heck are you?")
hello world!
(None,)
>>> print ("hello world!")
print ("who the heck are you?")
hello world!
>>> lucky=7
>>> print lucky
SyntaxError: invalid syntax (<pyshell#6>, line 1)
>>> print ("lucky")
lucky
>>> lucky
7
>>> print one=2
SyntaxError: invalid syntax (<pyshell#9>, line 1)
>>> one=2
>>> one
2
>>> two=2
>>> one two
SyntaxError: invalid syntax (<pyshell#13>, line 1)
>>> one, two
(2, 2)
>>> red=5
>>> blue=10
>>> print red,blue
SyntaxError: invalid syntax (<pyshell#17>, line 1)
>>> red,blue
(5, 10)
>>> yellow=red
>>> red,blue,yellow
(5, 10, 5)
>>> print ("hello world")
hello world
>>> print (\"hellow world"\)
SyntaxError: unexpected character after line continuation character (<pyshell#22>, line 1)
>>> print (\"hello world\")
SyntaxError: unexpected character after line continuation character (<pyshell#23>, line 1)
>>> print ("bouncy")*2
bouncy
Traceback (most recent call last):
File "<pyshell#24>", line 1, in <module>
print ("bouncy")*2
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
>>> print ("bouncy")
bouncy
>>> one=2
>>> one*2
4
>>> print ("hello")+2
hello
Traceback (most recent call last):
File "<pyshell#28>", line 1, in <module>
print ("hello")+2
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
>>> print ("helo")*2
helo
Traceback (most recent call last):
File "<pyshell#29>", line 1, in <module>
print ("helo")*2
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
>>> print len ("hello world!")
SyntaxError: invalid syntax (<pyshell#30>, line 1)
sorry for all the newbness and long post:$ just needa get differences between the version sorted so i can continue with the tutorials