runtime
56 / 500
question 56 Strings & Text · medium

Which invoice was cancelled?

In the Online Retail II data, a cancellation's invoice number is the original number with a capital C in front: C489528 cancels invoice 489528. Numbers arrive from a spreadsheet export, sometimes with spaces around them. This program should print cancels 489528 for a cancellation and sale 489438 for a normal invoice, but it reports every invoice as a sale. There is more than one bug.

Inputinvoice, an invoice number as exported, possibly with spaces at the ends
Printscancels <number> (the number without the C), or sale <number>
Examples" C489528" → cancels 489528; "489438" → sale 489438; "C536379 " → cancels 536379
Expected output1 line
  1. 1cancels 489528

Loading your progress…

Which invoice was cancelled? — Python practice · Runtime