ho una tupla di stringhe che si compone di due frasienumerare frasi in pitone
a = ('What', 'happened', 'then', '?', 'What', 'would', 'you', 'like', 'to', 'drink','?')
Ho provato questo
for i,j in enumerate(a):
print i,j
che dà
0 What
1 happened
2 then
3 ?
4 What
5 would
6 you
7 like
8 to
9 drink
10 ?
mentre ciò che mi serve è questo
0 What
1 happened
2 then
3 ?
0 What
1 would
2 you
3 like
4 to
5 drink
6?
Come faccio a saperlo erano la prima linea termina nella tupla? Il punto interrogativo è un separatore? –
Hai una tupla di stringhe nel tuo esempio. Questo è diverso da ciò che affermi nella descrizione, "Una stringa di due frasi" – user3636636
@ Tanveer Alam: sì, è corretto, '?' è un separatore ma può anche essere qualsiasi altro segno di punteggiatura. – user3635159