t; The -- needs to be replaced with < or > where applicable.
>
> and I want the "brick" out of that string (the second brick that is). How
> can I get just the "brick" out of that string?
> --
> View this message in context:
> http://www.nabble.com/Gett
Alexnb wrote:
"hello"[0]
'h'
"hello"[0] == "<"
False
"hello"[0] == "h"
True
"hello".startswith("h")
True
really? That's just like C. I thought that it would fail because of the way
lists work. Thanks!
what way?
the first three will fail if the string is empty.
>>> ""[0]
Tra
o"[0] == "<"
> False
>>>> "hello"[0] == "h"
> True
>>>> "hello".startswith("h")
> True
>
> Bye,
> bearophile
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
really?
On Jul 17, 9:50 am, Alexnb:
> how can I test to see if the first char of a string is "<"?
I suggest you to try the interactive shell:
>>> "hello"[0]
'h'
>>> "hello"[0] == "<"
False
>>> "hello"[0] == "h"
True
>>> "hello".startswith("h")
True
Bye,
bearophile
--
http://mail.python.org/mailman/list
;
> >>> s.split('>', 1)[1].split('<')[0]
> brick
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
Excellent! it works. But I have one more question. How can I test to see if
the first character of a string is what I want, for example, how can I test
to see if the first char of a string is "<"?
--
View this message in context:
http://www.nabble.com/Getting-a-unknown-word-out-of-a-list-with-no-spaces-tp18502758p18503367.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list
Alexnb wrote:
s = '--a href="/browse/brick"--brick--/a--'
s
'--a href="/browse/brick"--brick--/a--'
''.join('<%s>' % l if i % 2 == 1 else l for i, l in
enumerate(s.split('--')))
' /browse/brick brick '
I'm sorry, I don't think I was being clear. I replaced the <'s with -- so it
would post on
in
> enumerate(s.split('--')))
> ' /browse/brick brick '
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
I'm sorry, I don't think I was being clear. I replaced the <'s with -- so it
would post online w/o actually makin
s = '--a href="/browse/brick"--brick--/a--'
s
'--a href="/browse/brick"--brick--/a--'
''.join('<%s>' % l if i % 2 == 1 else l for i, l in
enumerate(s.split('--')))
'brick'
--
http://mail.python.org/mailman/listinfo/python-list
View this message in context:
http://www.nabble.com/Getting-a-unknown-word-out-of-a-list-with-no-spaces-tp18502758p18502758.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list