forked from bedroombuilds/python2rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.py
More file actions
30 lines (21 loc) · 680 Bytes
/
strings.py
File metadata and controls
30 lines (21 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
if __name__ == "__main__":
alice = "I like dogs"
bob = alice.replace("dog", "cat")
print("Alice says:", alice)
print("Bob says:", bob)
print("Bob says again:", bob)
pangram = "the quick brown fox jumps over the lazy"
print("Pangram:", pangram)
print("Words in reverse")
for word in reversed(pangram.split()):
print(">", word)
chars = [c for c in pangram]
chars = sorted(set(chars))
string = ""
for c in chars:
string += c
string += ", "
chars_to_trim = ' ,'
trimmed_str = string.strip(chars_to_trim)
print("Used characters:", string)
print("Trimmed characters:", trimmed_str)