MariyanGrigorov

Python-Strange response behavior in output

Jun 27th, 2024 (edited)
797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | Software | 0 0
  1. strings = input().replace(' ', '')
  2. count = {}
  3.  
  4. for string in strings:
  5.     count[string] = count.get(string, 0) + 1
  6. leather = '\n'.join({f'{letter} -> {num}' for letter, num in count.items()})
  7. print(leather)
  8.  
  9. # input = text
  10. # correct answer = t -> 2 e -> 1 x -> 1
  11. # wrong answer 80 percent in case = e -> 1 x -> 1 t -> 2
  12.  
Tags: Python_weird
Advertisement
Add Comment
Please, Sign In to add comment