[Tutor] Python beginner having troubles understanding word lists and character lists
steve at pearwood.info
Thu Apr 29 01:56:04 CEST 2010
On Thu, 29 Apr 2010 05:06:22 am Daniel wrote:
> Hello, I'm a beginner programmer, trying to learn python. I'm
> currently reading The programming Historian,
> I stumbled into lists of words and lists of characters. I have no
> explications in that book for those two and I didn't found some
> explications on the web. Could you point me to a link or something
> where I can read about them? I don't seem to understand why they are
> thank you so much!
Is English your first language? I ask because "list of words" is
ordinary English, and the meaning in Python is hardly different.
In English, a list of words is a collection of words. There is no
official way of writing a list in English. Here are three examples:
red blue yellow green
king, queen, emperor, peasant, duke, serf
In Python, a word is just a string with no spaces inside it:
"not a word"
and a list can be created with square brackets and commas:
["red", "blue", "yellow", "green"]
Characters are single letters, digits or punctuation marks:
a e i o u 2 4 6 8 . ? $ %
In Python, characters are just strings, and you can put them in a list:
["a", "e", "i", "o", "u", "2", "4", "6", "8", ".", "?", "$", "%"]
Hope this helps you.
More information about the Tutor