Skip to content

Commit f819d93

Browse files
committed
Redid Tuples and Sets - Exercise
1 parent 9ef61bc commit f819d93

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Advanced/1.Stacks, Queues, Tuples and Sets/Tuples and Sets - Exercise/01. Unique Usernames.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
unique_usernames = {input() for username in range(names)}
44

5-
[print(username) for username in unique_usernames]
5+
print('\n'.join(unique_usernames))
66

77

88
# print('\n'.join({input() for username in range(int(input()))}))
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
lines_with_elements = int(input())
1+
lines = int(input())
22

3-
unique_elements = set()
3+
periodic_table = set()
44

5-
for elements in range(lines_with_elements):
5+
for element in range(lines):
66
chemical_elements = input().split()
7-
[unique_elements.add(elem) for elem in chemical_elements]
7+
[periodic_table.add(elem) for elem in chemical_elements]
88

9-
print('\n'.join([element for element in unique_elements]))
9+
print('\n'.join(periodic_table))
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
symbols = tuple(sorted([char for char in input()])) # makes a tuple containing of every single character
1+
lines = int(input())
22

3-
counted_characters = [] # checks if a character is already counted
3+
periodic_table = set()
44

5-
for symbol in symbols:
5+
for element in range(lines):
6+
chemical_elements = input().split()
7+
[periodic_table.add(elem) for elem in chemical_elements]
68

7-
if symbol not in counted_characters:
8-
print(f"{symbol}: {symbols.count(symbol)} time/s")
9-
counted_characters.append(symbol)
9+
print('\n'.join(periodic_table))

0 commit comments

Comments
 (0)