Inventory Frequency Counter
E · easyP · Verified PYQarraysstringshashing
Problem
Given a string of space-separated item names (inventory), count how many times each item appears. If the input contains any digit, print “Invalid input” and stop. Print each item and its count.
Example
Input
apple banana apple orange banana apple
Output
apple 3 banana 2 orange 1
Split by space. Check each char — if digit found, print Invalid input and return. Else use dict to count frequency.
Note: If input contains digits e.g. "apple123 banana" → print "Invalid input"