ret = "" word = "hello" for c in word: ret = c + ret print ret h eh leh lleh olleh ret = "" for c in word: ret = ret + c print ret h he hel hell hello print word.split() ['hello'] phrase = "it is a lovely day today" print phrase.split() ['it', 'is', 'a', 'lovely', 'day', 'today'] phraseSplit = phrase.split() for w in phrase.split(): print w it is a lovely day today print phrase.count("is") 1 print "This is a lovely day".count("is") 2 phrase = "This is a lovely day" lst = phrase.split() print lst ['This', 'is', 'a', 'lovely', 'day'] phrase2 = " ".join(lst) print phrase2 This is a lovely day phase3 = "-".join(lst) print phase3 This-is-a-lovely-day lst.append("today") print lst ['This', 'is', 'a', 'lovely', 'day', 'today'] if "day" in lst: print "day is in there" day is in there if "a" in phrase: print "a is in phrase" a is in phrase word = "hello" word[1] = "a" Traceback (most recent call last): File "C:\Users\Susan\AppData\Local\Enthought\Canopy\User\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in word[1] = "a" TypeError: 'str' object does not support item assignment print lst ['This', 'is', 'a', 'lovely', 'day', 'today'] lst[1] = "was" print lst ['This', 'was', 'a', 'lovely', 'day', 'today'] print phrase This is a lovely day print phrase.split() ['This', 'is', 'a', 'lovely', 'day'] x = phrase.split() print x ['This', 'is', 'a', 'lovely', 'day'] print x.split() Traceback (most recent call last): File "C:\Users\Susan\AppData\Local\Enthought\Canopy\User\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in print x.split() AttributeError: 'list' object has no attribute 'split' print phrase This is a lovely day print phrase.split("a") ['This is ', ' lovely d', 'y'] print phrase.split("y") ['This is a lovel', ' da', ''] phrase = "today is a really warm and cold day how is that?" answer = [] for word in phrase.split(): if word.startswith("t"): answer.append("word") print answer ['word', 'word'] answer = [] for word in phrase.split(): if word.startswith("t"): answer.append(word) print answer ['today', 'that?'] print "123"*2 123123 print int("123")*2 246 print int("a")*2 Traceback (most recent call last): File "C:\Users\Susan\AppData\Local\Enthought\Canopy\User\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in print int("a")*2 ValueError: invalid literal for int() with base 10: 'a'