Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > free.it.comp.lang.python > #2

Re: Banale ma utile

X-Received by 10.157.16.10 with SMTP id h10mr5167434ote.95.1487501354749; Sun, 19 Feb 2017 02:49:14 -0800 (PST)
X-Received by 10.157.2.235 with SMTP id 98mr264763otl.3.1487501354720; Sun, 19 Feb 2017 02:49:14 -0800 (PST)
Path csiph.com!1.us.feeder.erje.net!feeder.erje.net!2.us.feeder.erje.net!newspeer1.nac.net!border2.nntp.dca1.giganews.com!nntp.giganews.com!e137no1400900itc.0!news-out.google.com!78ni1003itm.0!nntp.google.com!e137no1400890itc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups free.it.comp.lang.python
Date Sun, 19 Feb 2017 02:49:14 -0800 (PST)
In-Reply-To <c8frls$5gi$1@lacerta.tiscalinet.it>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=79.46.52.1; posting-account=y14M1QoAAABQakk-2dDBGX-UEhPRG_hK
NNTP-Posting-Host 79.46.52.1
References <c8frls$5gi$1@lacerta.tiscalinet.it>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <851f9136-fb87-4262-885b-0478ba817ffd@googlegroups.com> (permalink)
Subject Re: Banale ma utile
From Francesco Palumbo <franzopal@gmail.com>
Injection-Date Sun, 19 Feb 2017 10:49:14 +0000
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Lines 35
Xref csiph.com free.it.comp.lang.python:2

Show key headers only | View raw


Il giorno mercoledì 19 maggio 2004 16:40:47 UTC+2, Armand Federico - INFO ha scritto:
> Devo scoprire se un elemento esiste in una lista
> 
> Se metto confini.index(nomeelemento) mi da errore nel caso non esista e mi
> da  l'indice nel caso esista
> 
> Il mio problema č:
> se l'elemento non esiste, devo fare la stessa cosa con un altro elemento.
> 
> Come posso evitare l'errore???
> 
> 
> ***
> Avevo provato con
> 
> if confini.index(nomeelemento):
>     return qualcosa
> else:
>     continue
> 
> ***
> Oppure con
> 
> if confini.index(nomeelemento)>-1:
>     return qualcosa
> else:
>     continue
> 
> Ma nel caso non venga trovato l'elemento da errore

if nomeelemento in confini:
    faiquesto()
else:
    faiquello()

Back to free.it.comp.lang.python | Previous | Next | Find similar


Thread

Re: Banale ma utile Francesco Palumbo <franzopal@gmail.com> - 2017-02-19 02:49 -0800

csiph-web