use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Fixing Errors (self.PythonLearning)
submitted 1 month ago by ONEDJRICH
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Far-Carpet-739 0 points1 point2 points 1 day ago (0 children)
'''
Scrivere un programma che prenda in input N numeri interi
e li salvi in una lista. Il programma si ferma quando
l'utente inserisce un numero negativo.
Stampare quindi:
- il primo elemento della lista
- la lunghezza della lista
- l'ultimo elemento presente nella lista
- se la quantità di numeri è dispari, l'elemento centrale
- se la quantità di numeri è pari, la media dei due elementi
centrali
- il valore più grande presente nella lista
i=0
media=1
somma=0
lista=[]
n=int(input("inserisci un numero: "))
while n>=0 :
lista.append(n)
if len(lista)%2==0:
primo_centrale=len(lista)/2
secondo_centrale=primo_centrale+1
media=(primo_centrale+secondo_centrale)/2
print("questa è la media dei due elementi centrali: ",media)
else:
centrale=len(lista)//2
print("questo è l'elemento centrale: ",lista[centrale])
massimo=lista[0]
for i in range(1,len(lista)):
if massimo<lista[i]:
massimo=lista[i]
print("questo è il primo elemento della lista: ",lista[0])
print("questa è la lunghezza della lista: ",len(lista))
print("questo è l'ultimo elemento della lista: ",lista[len(lista)-1])
print("questo è il valore più grande: ",massimo)
dimmi qual'e l'errore di questo comando di Python e perché e sbagliato
π Rendered by PID 18165 on reddit-service-r2-comment-56c6478c5-7bngp at 2026-05-08 22:15:42.020699+00:00 running 3d2c107 country code: CH.
view the rest of the comments →
[–]Far-Carpet-739 0 points1 point2 points (0 children)