Brand new coder - need somewhere to practice


#1

I am learning Python and want an environment with the great console that you learn with, so I can just type code and see the results straight away on the right. You are not able to do this after you finish a particular lesson, I've downloaded Python but I can't even seem to do things like Print without receiving an error message


#2

I have just the right resource for you @joshnlewis !

https://repl.it/sessions


#3

Thank Dave I'll have a look


#4

We're used to working with Python 2 over here. Python 3 has some differences, which include print. It is now a function so much be written like a function call,

print ()

#5

Right I see, bit confusing. I used repl.it to practice some code, I was trying this but again having errors

g = ("golf")
h = ("hotel")

print ("I went to the %s and played a great round of %s")(g,h) %

Invalid syntax apparently, does it matter if I learn python 2 first when python 3 is out? Thanks for your help


#6

The old string formatting still works in Python 3, but we must enclose the entire expression in that argument...

print (" ... %s ... %s" % (g, h))

Plain strings are written as quoted text. The parens are window dressing that make a string look like a tuple.

g = 'golf'
h = "hotel"

Python 3 has a new string format function.

print (' ... {} ... {}".format(g, h))

#7

Thanks for this, its very helpful