simon.brunning at gmail.com
Tue Nov 15 10:35:00 CET 2005
On 14/11/05, john boy <xray_alpha_charlie at yahoo.com> wrote:
> using the following program:
> prefixes = "JKLMNOPQ"
> suffix = "ack"
> for letter in prefixes:
> print letter + suffix
> if prefixes == "O" or "Q"
Here you need:
if prefixes == "O" or prefixes == "Q"
> print letter + "u" + suffix
> For this program I am trying to combine the individual letters with the
> suffix to form names...but for O and Q I need to add in a "u" so the
> spelling is correct...I am having a hard time pulling just the O and Q out
> of the list of letters for manipulation...instead it is adding "u" to all
> the letters when combining with the suffix...apparently its due the fact
> that O and Q are present in the entire "string"......anybody have some
> suggestions for this??...
It's not because "O and Q are present in the entire string" - it's
because your expression
prefixes == "O" or "Q"
(prefixes == "O") or ("Q")
Since a string containing a value always evaluates as true, your
expression was always true, too.
simon at brunningonline.net,
More information about the Python-list