Re: [Tutor] Problem with code interating thri a list

2016-08-03 Thread Peter Otten
Chris Clifton via Tutor wrote: > I have been practicing with strings. Splitting them, joining them, > changing case. All has been going well but came across a exercise in one > of the code practice sites that has you changing the case of different > characters in a string. Anything in upper cas

Re: [Tutor] Problem with code interating thri a list

2016-08-02 Thread Alan Gauld via Tutor
On 03/08/16 00:30, Alan Gauld via Tutor wrote: >> if item == item.lower(): I meant to add that the string islower() method is probably more readable: if item.islower() Also that you could use a list comprehension to do this without converting to a list initially: def conveert(text):

Re: [Tutor] Problem with code interating thri a list

2016-08-02 Thread Danny Yoo
On Tue, Aug 2, 2016 at 7:59 AM, Chris Clifton via Tutor wrote: > My Logic: Since a string is immutable, I converted it to a list to separate > out the characters and keep them in order. Idea is to change the case of the > characters in the list then run a join to convert it back to a string.

Re: [Tutor] Problem with code interating thri a list

2016-08-02 Thread Alan Gauld via Tutor
On 02/08/16 15:59, Chris Clifton via Tutor wrote: > My Logic: Since a string is immutable, I converted it to a list That is certainly one approach but your solution has some snags. In fact its probably not necessary unless you want to play with big strings. You could just build a new string from

[Tutor] Problem with code interating thri a list

2016-08-02 Thread Chris Clifton via Tutor
Hello Everyone,    I have been practicing with strings.  Splitting them, joining them, changing case.  All has been going well but came across a exercise in one of the code practice sites that has you changing the case of different characters in a string.  Anything in upper case is converted to