[Tutor] Fwd: converting upper case to lowercase and vice-versa
Bod Soutar
bodsda at googlemail.com
Fri Mar 15 16:45:27 CET 2013
Did'nt realise this went offlist, my fault
-- Bodsda
---------- Forwarded message ----------
From: Shall, Sydney <sydney.shall at kcl.ac.uk>
Date: 15 March 2013 14:43
Subject: Re: [Tutor] converting upper case to lowercase and vice-versa
To: Bod Soutar <bodsda at googlemail.com>
On 15/03/2013 14:30, Bod Soutar wrote:
On 15 March 2013 13:52, Shall, Sydney <sydney.shall at kcl.ac.uk> wrote:
I am just learning Python and my book does not solve my problem.
I have not yet been successful in searching the Python 2.7.3 tutorial
I am doing an encryption exercise.
Python 2.7.3
MAC OS X 10.6.8
What is the correct syntax to covert English characters from uppercase to
lowercase and from lowercase to uppercase?
With many thanks,
Sydney
--
mystring = "THIS is A string"
newstring = ""
for item in mystring:
if item.isupper():
newstring += item.upper()
else:
newstring += item.lower()
print newstring
Thanks Bod,
This is most helpful.
In fact, your syntax allows me to now simplify my code.
Sydney
--
Professor Sydney Shall,
Department of Haematological Medicine,
King's College London,
Medical School,
123 Coldharbour Lane,
LONDON SE5 9NU,
Tel & Fax: +44 (0)207 848 5902,
E-Mail: sydney.shall,
[correspondents outside the College should add; @kcl.ac.uk]
www.kcl.ac.uk
More information about the Tutor
mailing list