On 2014-10-12 22:16, Marko Rauhamaa wrote:
> is equivalent with
>
> while ans.lower()[0] != 'y':
> ans = input('Do you like python?')
And still better improved with
while ans[:1].lower() != 'y':
ans = input('Do you like python?')
in the event that len(ans)==0 (a situation which will crash the
various current examples).
It also only expends the effort to lowercase 0-or-1 characters,
rather than lowercasing an entire string just to throw away
everything except the first character.
-tkc
--
https://mail.python.org/mailman/listinfo/python-list