Non hai bisogno di caricare tutta la lista in memoria.

Uguale ma con un generatore.

print sum(x for x in xrange(3, 1000, 3) if not x % 3 or not x % 5)

Il giorno 13 febbraio 2015 09:50, Diego Barrera <diegonebarr...@yahoo.it>
ha scritto:

> Il 12/02/2015 16:14, Marco Beri ha scritto:
>
>>
>>     E naturalmente Project Euler:
>>     https://projecteuler.net/
>>
>>
>> Questa rischia di diventare una droga perĂ²...
>>
>> Ne sono uscito con fatica :-)
>>
>>  Fico!!
> La mia soluzione al primo problema ;)
>
> |print  sum([xfor  xin  xrange(3,1000,3)if  not  x %3  or  not  x %5])|
>
>
>
> _______________________________________________
> Python mailing list
> Python@lists.python.it
> http://lists.python.it/mailman/listinfo/python
>
_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python

Rispondere a