Hi, I'm new to Python and I'm working with strings and for loops.
Can someone tell me how I can alternate capital and lowercase letters in a sentence? I know how to convert an all-capital word into lowercase, and vice versa. But I can't seem to figure out how to alternate letters in a sentence.
For example, if I write: The dog is sitting.
I would like it to come out as: ThE DoG Is sItTiNg.
Thank you!
Case Manipulation - strings and for loops
Page 1 of 11 Replies - 366 Views - Last Post: 11 March 2013 - 05:51 PM
Replies To: Case Manipulation - strings and for loops
#2
Re: Case Manipulation - strings and for loops
Posted 11 March 2013 - 05:51 PM
Think about it differently.
Can you make "The dog is sitting." come out as "T.h.e. .d.o.g. .i.s. .s.i.t.t.i.n.g...". You must break your sentence into letters. Once you can do that, then the solution is easy. Consider that a string can be treated as a list of characters.
Can you make "The dog is sitting." come out as "T.h.e. .d.o.g. .i.s. .s.i.t.t.i.n.g...". You must break your sentence into letters. Once you can do that, then the solution is easy. Consider that a string can be treated as a list of characters.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|