solve it but still having error somewhere

A cashier distributes change using the maximum number of five-dollar bills, followed by one-dollar bills. Write a single statement that assigns num_ones with the number of distributed one-dollar bills given amount_to_change. Hint: Use %.

Sample output with input: 19
Change for $ 19
3 five dollar bill(s) and 4 one dollar bill(s)

this is how i solved it but am still getting error on some part

amount_to_change = int(input())
num_fives = amount_to_change // 5
''' Your solution goes here '''
num_ones = 19 % 5
print('Change for $', amount_to_change)
print(num_fives, 'five dollar bill(s) and', num_ones, 'one dollar bill(s)')
1

1 Answer

You may not use a hard-coded 19 , but rather amount_to_change, both 5 and 1 dollar bills

amount_to_change = int(input("Enter an amount"))
num_fives = amount_to_change // 5
num_ones = amount_to_change % 5
print('Change for $', amount_to_change)
print(num_fives, 'five dollar bill(s) and', num_ones, 'one dollar bill(s)')

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like