Re: A technique from a chatbot

Liste des GroupesRevenir à cl python 
Sujet : Re: A technique from a chatbot
De : michael.stemper (at) *nospam* gmail.com (Michael F. Stemper)
Groupes : comp.lang.python
Date : 03. Apr 2024, 23:36:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uuki4v$5i2o$1@dont-email.me>
References : 1 2
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 03/04/2024 13.45, Gilmeh Serda wrote:
On 2 Apr 2024 17:18:16 GMT, Stefan Ram wrote:
 
first_word_beginning_with_e
 Here's another one:
 
def ret_first_eword():
...     return [w for w in ['delta', 'epsilon', 'zeta', 'eta', 'theta'] if w.startswith('e')][0]
...
ret_first_eword()
'epsilon'
Doesn't work in the case where there isn't a word starting with 'e':
  >>> def find_e( l ):
  ...   return [w for w in l if w.startswith('e')][0]
  ...
  >>> l = ['delta', 'epsilon', 'zeta', 'eta', 'theta']
  >>> find_e(l)
  'epsilon'
  >>> l = ['The','fan-jet','airline']
  >>> find_e(l)
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "<stdin>", line 2, in find_e
  IndexError: list index out of range
  >>>
--
Michael F. Stemper
If it isn't running programs and it isn't fusing atoms, it's just bending space.

Date Sujet#  Auteur
2 Apr 24 * A technique from a chatbot15Stefan Ram
2 Apr 24 +* Re: A technique from a chatbot12Piergiorgio Sartor
2 Apr 24 i+* Re: A technique from a chatbot8Thomas Passin
4 Apr 24 ii`* Re: A technique from a chatbot7Mark Bourne
4 Apr 24 ii +* Re: A technique from a chatbot2<avi.e.gross
5 Apr 24 ii i`- Re: A technique from a chatbot1Mark Bourne
4 Apr 24 ii +- Re: A technique from a chatbot1Thomas Passin
5 Apr 24 ii `* Re: A technique from a chatbot3Stefan Ram
5 Apr 24 ii  +- Re: A technique from a chatbot1Stefan Ram
5 Apr 24 ii  `- Re: A technique from a chatbot1Mark Bourne
3 Apr 24 i+- Re: A technique from a chatbot1<avi.e.gross
3 Apr 24 i+- Re: A technique from a chatbot1Thomas Passin
3 Apr 24 i`- Re: A technique from a chatbot1<avi.e.gross
3 Apr 24 +- Re: A technique from a chatbot1Pieter van Oostrum
3 Apr 24 `- Re: A technique from a chatbot1Michael F. Stemper

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal