Newbie Q: Adding String to list
DP
pennedinil at delete.excite.com
Thu Aug 1 02:27:22 EDT 2002
Newbie questions - I'm trying to improve my skills by trying to code more
efficiently, and all help will be appreciated.
I have an array
AA = ["a","b","c"]
I'd like to add text, let's say
x = "x"
to each element of the array, to get
AAx = ["xa","xb","xc"]
What's the simplest way to accomplish this?
I'd like to avoid looping over AA.
-------
And if
X = ["x","y","z"]
what's the best way to generate (the equivalent of)
AAXX = |"xa","xb","xc"|
|"ya","yb","yc"|
|"za","zb","zc"|
or
AAX = ["xa","xb","xc","ya","yb","yc","za","zb","zc"]
-------
OR
if I have an array with N elements, what's the best way to convert this into
a 2 dimensional array with (n X m) elements, where n*m = N. And vice versa.
I need to be able to do this with numeric data too, but I should be able to
figure that out from any hints I receive from above.
Thanks in advance.
--
DP
----------------------------------------------------------------------------
---
Delete the "delete" before responding via email to
pennedinil at delete.excite.com
pennedinl at excite dot com
----------------------------------------------------------------------------
---
More information about the Python-list
mailing list