Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Trasformare file di testo in un insieme

G
Giacomozm (1440 points)
19 59 68
in Es3 by (1.4k points)
closed by
Come faccio a convertire un file di testo in un' insieme da inserire poi in una funzione predefinita?
523 views
closed with the note: deadline expired

4 Answers

Neo (6720 points)
7 27 37
by (6.7k points)
Utilizza la funzione set(nomevariabile)!
A
AlessioL98 (500 points)
1 7 14
by (500 points)
Apri il file in modalità lettura, e utilizza il comando var=nomefile.readlines() per "leggere" i singoli elementi. A questo punto utilizza il comando set(var) per inserirli in un insieme.
G
Giacomozm (1440 points)
19 59 68
by (1.4k points)
però nella lista mi mette ogni elemento in formato 'elemento\n'
andrea.sterbini (207920 points)
750 1267 2373
by (208k points)
In un insieme di cosa, esattamente? Di linee?
G
Giacomozm (1440 points)
19 59 68
by (1.4k points)
si, senza però che mi salvi ogni elemento con \n alla fine
cristofer.valiante (1690 points)
3 8 21
by (1.7k points)
giacomozm per togliere la "\n" devi settare la variabile stringa con [:-1]
G
Giacomozm (1440 points)
19 59 68
by (1.4k points)
Col readline giusto?
andrea.sterbini (207920 points)
750 1267 2373
by (208k points)
NO CODICE, PLEASE