Вот так работает...
price_list=[]
user_input=float(input('Please enter amount"s->'))
price_list.append(user_input)
while user_input!=000:
user_input=float(input('Please enter amount"s->'))
price_list.append(user_input)
price_list.remove(000)
full_sum=sum(price_list)
sum_cents=(full_sum*100)/5
if sum_cents<2.5:
total=round(full_sum-0.05)
print('Total Price',total)
elif sum_cents>2.5:
total=round(full_sum+0.05)
print('Total Price',total)
А вот так нет....
price_list=[]
user_input=float(input('Please enter amount"s->'))
price_list.append(user_input)
while user_input!='':
user_input=float(input('Please enter amount"s->'))
price_list.append(user_input)
price_list.remove('')
full_sum=sum(price_list)
sum_cents=(full_sum*100)/5
if sum_cents<2.5:
total=round(full_sum-0.05)
print('Total Price',total)
elif sum_cents>2.5:
total=round(full_sum+0.05)
print('Total Price',total)
То есть по сути не работает выход из цикла по пробелу от пользователя, но в силу своих скудных познаний я не могу понять почему. ведь здесь :
while user_input!=''
Нет никаких проверок. Дебагер показывает ошибку здесь:
while user_input!='':
(на этой строке) user_input=float(input('Please enter amount"s->'))
Возникло исключение: ValueError could not convert string to float: ''
И как правильно решить или обойти эту проблему? Как я не пытался, не получается. Спасибо