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.
Input
invoice, an invoice number as exported, possibly with spaces at the endsPrints
cancels <number> (the number without the C), or sale <number>Examples
" C489528" → cancels 489528; "489438" → sale 489438; "C536379 " → cancels 536379Expected output1 line
- 1cancels 489528