Fundamental Problems
Considering you're learning, I would like to comment on what I see are fundamental problems with the function, not just how concise you can make the code.
No return value
A very big part of programming is making your functions modular, and we usually do this by breaking down the task into pieces which can be repeated. Using print statements like you did will print out to the console and might even make sense for your current problem, but what happens when you want to use this elsewhere? What if you want to save the fancy string to disk?
The answer to this is to return the string as the other answers have done. Then when you have the string you can do what you want with it like printing it or writing it to disk.
You should get into the habit of returning values from your functions.
Misleading Names
The function name implies that it returns a string from a list. Imagine you come back to your code four months from now and try to use this function to write to a file you would be justified into writing something like this:
fancy_string = list_to_string(groceries)
with open('groceries.txt', 'w') as groceries_file:
groceries_file.write(fancy_string)
However, this will not work, because there is no return value here.
Naming is a seriously hard thing to do in programming, so consider your names carefully.
Python Style
Now into more minor things I'd like to point out to make the code more pythonic.
enumerate is your friend
This loop fragment:
for i in range(len(someList)):
newString = str(someList[i])
can be replaced with:
for i, newString in enumerate(someList):
Also now replace instances of someList[i] with newString:
def listToString(someList):
for i, newString in enumerate(someList):
if i == (len(someList)-1):
print('and ' + str(newString))
else:
print(newString, end=', ')
Even though in this case you should be using answers more along the line of the other posts it's good to know about enumerate for cases where you need the index along with the element of a list. I encourage you to use the Python for-loop construct without indexing things as much as possible.
PEP 8
As others have pointed out, the code is not to the Python standard PEP 8.
While I'm not aware of code that strictly follows PEP 8 you should take a look at it to see what it looks like.
range(len(_))
in Python. Just iterate over the collection itself. If you need the indices as well, useenumerate
. \$\endgroup\$