Skip to content

Commit 809c404

Browse files
authored
used f string
1 parent 845b464 commit 809c404

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Collections/CollectionsOrderedDict.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Domain : Python
55
Author : Ahmedur Rahman Shovon
66
Created : 15 July 2016
7+
Updated : 08 February 2023
78
Problem : https://www.hackerrank.com/challenges/py-collections-ordereddict/problem
89
"""
910

@@ -16,8 +17,9 @@
1617
record_list = re.split(r"(\d+)$", input().strip())
1718
item_name = record_list[0]
1819
item_price = int(record_list[1])
19-
item_od[item_name] = (
20-
item_price if item_name not in item_od else item_od[item_name] + item_price
21-
)
20+
if item_name not in item_od:
21+
item_od[item_name] = item_price
22+
else:
23+
item_od[item_name] = item_od[item_name] + item_price
2224
for i in item_od:
23-
print(i + str(item_od[i]))
25+
print(f"{i}{item_od[i]}")

0 commit comments

Comments
 (0)