On 22/10/2014 21:57, Joel Goldstick wrote:
On Wed, Oct 22, 2014 at 4:30 PM, Seymore4Head
<Seymore4Head@hotmail.invalid> wrote:
def nametonumber(name):
     lst=[""]
     for x,y in enumerate (name):
         lst=lst.append(y)
     print (lst)
     return (lst)
a=["1-800-getcharter"]
print (nametonumber(a))#18004382427837


The syntax for when to use a () and when to use [] still throws me a
curve.
() is tuples which are immutable which means that the items can't be
changed.  [] is list which means that each item can be changed.
Tuples are useful because they can be used as keys in dictionaries and
are guarantied not to change.  Lists are useful because they can be
updated.


This is wrong, commas define tuples.

type mytest.py
a = 1, 2
print(type(a))

c:\Users\Mark\MyPython>mytest.py
<class 'tuple'>


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to