我工作的家庭作业语法错误,它看起来像这样:蟒蛇3.5.1上如果else语句
def main():
keep_going = 'y'
number_of_salespeople = 0
while keep_going == 'y' or keep_going == 'Y':
process_sales()
number_of_salespeople += 1
keep_going = input('Are there more salespeople? (enter y or Y for yes) ')
print(' ')
print('There were', number_of_salespeople, 'salespeople today.')
def process_sales():
print(' ')
name = input('What is the salesperson\'s name? ')
first_sale_amount = float(input('What is', name, '\'s first sale amount? '))
while 0 <= first_sale_amount <= 25000:
print('Error: that is not a valid sales amount. The amount must be greater than 0')
first_sale_amount = float(input('Please enter a correct sale amount: '))
highest_sale = first_sale_amount
lowest_sale = first_sale_amount
average_sale = first_sale_amount
number_of_sales = float(input('How many sales did', name, 'make this month? '))
for number in range(2, number_of_sales + 1):
sale_amount = float(input('Enter', name, '\'s time for sale #' + str(number) + ': '))
while 0 <= sale_amount <= 25000:
print('Error: that is not a valid sales amount. The amount must be greater than 0')
sale_amount = float(input('Please enter a correct sale amount: '))
if sale_amount > highest_sale:
highest_sale = sale_amount
else sale_amount < lowest_sale:
lowest_sale = sale_amount
total_sales += sale_amount
average_sale = (first_sale_amount + total_sales)/number_of_sales
print('The highest sale for', name, 'was', \
format(highest_sale, ',.2f'), \
sep='')
print('The lowest sale for', name, 'was', \
format(lowest_sale, ',.2f'), \
sep='')
print('The average sale for', name, 'was', \
format(average_sale, ',.2f'), \
sep='')
main()
我有错误是在if else语句向底部,
if sale_amount > highest_sale:
highest_sale = sale_amount
else sale_amount < lowest_sale:
lowest_sale = sale_amount
错误看起来是这样的:
Syntax Error: else sale_amount < lowest_sale:: , line 58, pos 24
我看不出是什么问题,谁能帮我找出其中t他的错误来自于。感谢您的帮助。
谢谢您的建议。我认为在代码中会出现更多的错误,我问到的错误只是第一个出现在调试器中的错误,我不能为了我的生活找出它为什么不起作用。我刚刚完成了整个任务,并且调试了一切并正常工作。谢谢你的时间。 – MauginRa