While loop - print several times but on 1 line.
bruno at modulix
onurb at xiludom.gro
Thu Jan 26 07:05:53 EST 2006
Danny wrote:
> I think I should paste some of the programs code a little more of what I
> want...
probably...
> var = 0
> while var <= 5:
> print a[t[var]]
> var = var +1
>
> a is a dectionary (very big) and t is a string of text. (if that's
> important right now).
It might be important...
> I'm just trying to make the value of a[t[var]] print on one line if that
> makes any sense...
> Sorry if I'm not explaining this very well and if my examples aren't
> very good, I am trying.
If I understand correctly, you have
- a dict 'a' which may look like this:
a = {'a': 1,
'b' : 2,
'c' : 3,
#etc
'z' : 26
}
that is, keys of this dict are one-letter-strings (we dont actually care
what the real values are, enough to know that it's what you want to
print out).
- a string 't' which may look like this :
t = 'abcdefghijklmnopqrstuvwxyz'
And you want to print someting like:
12345
(that is, the dict values which have one of the 5 fisrt letters of t as
keys)
Is that what you actually want ?
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list