Problems with string and lists (searching and replaceing)
jblazi
jblazi at hotmail.com
Sat Sep 20 17:51:30 EDT 2003
On Sat, 20 Sep 2003 21:30:37 +0000, Bengt Richter wrote:
> For the above, what is wrong with
>
> >>> def test():
> ... s = 'helo world'
> ... print s
> ... s = s.replace('helo','hello',1)
> ... print s
> ...
> >>> test()
> helo world
> hello world
Nothing is wrong with that, of course, but my code is something like this:
def vergleiche_woerter(eingabe,wort):
eing = mysplit(eingabe)
wo = mysplit(wort)
ergebnis=['-','-','-','-','-']
# Suche zuerst nach Bullen
for i in range(len(eing)):
if eing[i] == wo[i]:
ergebnis[i] = '*'
eing[i]=wo[i] = None
for i in range(len(eing)):
if eing[i] == None: continue
if eing[i] in wo:
j = wo.index(eing[i])
ergebnis[i] = '.'
wo[j] = None
return join(ergebnis,'')
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
More information about the Python-list
mailing list