+ 1
What was the error in this program?
5 Réponses
0
https://code.sololearn.com/cXxZ7S3A2hmH/?ref=app
Your code has indentation errors. Above code is clear code
+ 2
Sindhuja Selvakumar
And You should enter all input at once
+ 1
True not true
And unnecessary indentations ,you can't just throw in a space or tab at any point ,
sum=0
count=0
average=0
while True:
try:
x=input("enter the input")
if x=="done":
break
value=float(x)
sum=value+sum
count=count+1
average=sum/count
except:
print("invalid number")
print (sum,count,average)
+ 1
Very bad indentation:
sum=0
count=0
average=0
while True:
try:
x=input("enter the input")
if x=="done":
break
else:
value=float(x)
sum=value+sum
count=count+1
average=sum/count
except:
print("invalid number")
print (sum,count,average)
+ 1
Additional to above mentioned answers please note that while True together with interactive input of user data does not work here in Playground. The code can be i.e. looks like:
https://code.sololearn.com/c6te60ps8DnA/?ref=app