无法获取程序 运行
Can't Get Program to Run
这是我的介绍程序class的一个片段,它在打开之前一直崩溃。它在第 12 行给出了语法错误,但我不知道如何修复它。
#defines the median
def median(data)
data=sorted(data)
#this happens if there is an odd amount of numbers in the count
if len(data)%2==1:
return(data[int((count-1)/2)])
#this happens if there is an even amount of numbers in the count
else:
return(data(int[((count-1/2)+(count+1/2)/2]))
count=0
#Creates a dictionary loop that inputs all numbers in the list
for data
numbers{count+=0}:
else
break
for number in numbers:
count=numbers[number]
尝试
#defines the median
def median(data)
data=sorted(data)
#this happens if there is an odd amount of numbers in the count
if len(data)%2==1:
return(data[int((count-1)/2)])
#this happens if there is an even amount of numbers in the count
else:
return(data(int[((count-1/2)+(count+1/2)/2]))
count=0
#Creates a dictionary loop that inputs all numbers in the list
for data # in what:
numbers{count+=1}: #your problem was that you weren't updating count 0+0 = 0
else
break
for number in numbers:
count=numbers[number]
看起来您的 for
循环在语法上不正确。应该类似于 for d in data:
另请参阅 Python for 循环的解释:
https://wiki.python.org/moin/ForLoop
这是我的介绍程序class的一个片段,它在打开之前一直崩溃。它在第 12 行给出了语法错误,但我不知道如何修复它。
#defines the median
def median(data)
data=sorted(data)
#this happens if there is an odd amount of numbers in the count
if len(data)%2==1:
return(data[int((count-1)/2)])
#this happens if there is an even amount of numbers in the count
else:
return(data(int[((count-1/2)+(count+1/2)/2]))
count=0
#Creates a dictionary loop that inputs all numbers in the list
for data
numbers{count+=0}:
else
break
for number in numbers:
count=numbers[number]
尝试
#defines the median
def median(data)
data=sorted(data)
#this happens if there is an odd amount of numbers in the count
if len(data)%2==1:
return(data[int((count-1)/2)])
#this happens if there is an even amount of numbers in the count
else:
return(data(int[((count-1/2)+(count+1/2)/2]))
count=0
#Creates a dictionary loop that inputs all numbers in the list
for data # in what:
numbers{count+=1}: #your problem was that you weren't updating count 0+0 = 0
else
break
for number in numbers:
count=numbers[number]
看起来您的 for
循环在语法上不正确。应该类似于 for d in data:
另请参阅 Python for 循环的解释: https://wiki.python.org/moin/ForLoop