Tips: 1. range can be stepped down in reverse order ex -> >>> range(10, 1, -2) [10, 8, 6, 4, 2]
2. you can directly get chars of string. ex -> >>> [i for i in 'foobar'] ['f', 'o', 'o', 'b', 'a', 'r'] also >>> 2 * 'f' 'ff' On Sun, Jan 31, 2010 at 3:56 AM, Shashwat Anand <anand.shash...@gmail.com>wrote: > seems like homework ;) > Can you paste your approach here ? > > On Sun, Jan 31, 2010 at 3:03 AM, invincible patriot < > invincible_patr...@hotmail.com> wrote: > >> >> hi >> i am stuck in few tasks can some one help me in that >> here are first few tasks >> >> 1 >> how can i print the following series, using a loop >> 15 >> 13 >> 11 >> ... >> 3 >> 1 >> -1 >> ======== >> 2 >> Write a small Python program that generates the list of all pairs of >> characters c and >> its doubling 2 c, where c moves through all the letters of the string >> "foobar" and prints it out. >> The result will look like: >> [(’f’, ’ff’), (’o’, ’oo’), (’o’, ’oo’), (’b’, ’bb’), (’a’, ’aa’), (’r’, >> ’rr’)] >> >> please help me out in these two tasks >> >> >> ------------------------------ >> Hotmail: Trusted email with powerful SPAM protection. Sign up >> now.<http://clk.atdmt.com/GBL/go/196390707/direct/01/> >> >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> http://mail.python.org/mailman/listinfo/tutor >> >> >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor