Skip to content

Commit

Permalink
used f string
Browse files Browse the repository at this point in the history
  • Loading branch information
arsho committed Feb 9, 2023
1 parent 845b464 commit 809c404
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Collections/CollectionsOrderedDict.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Domain : Python
Author : Ahmedur Rahman Shovon
Created : 15 July 2016
Updated : 08 February 2023
Problem : https://www.hackerrank.com/challenges/py-collections-ordereddict/problem
"""

Expand All @@ -16,8 +17,9 @@
record_list = re.split(r"(\d+)$", input().strip())
item_name = record_list[0]
item_price = int(record_list[1])
item_od[item_name] = (
item_price if item_name not in item_od else item_od[item_name] + item_price
)
if item_name not in item_od:
item_od[item_name] = item_price
else:
item_od[item_name] = item_od[item_name] + item_price
for i in item_od:
print(i + str(item_od[i]))
print(f"{i}{item_od[i]}")

0 comments on commit 809c404

Please sign in to comment.