-
Notifications
You must be signed in to change notification settings - Fork 1
/
all_capital.py
52 lines (40 loc) · 1.14 KB
/
all_capital.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# script by Ruchir Chawdhry
# released under MIT License
# github.com/RuchirChawdhry/Python
# ruchirchawdhry.com
# linkedin.com/in/RuchirChawdhry
"""
Write a program that accept a sequence of lines* and prints the lines
as input and prints the lines after making all the characters
in the sequence capitalized.
*blank line or CTRL+D to terminate
"""
import sys
def all_caps():
lines = list()
while True:
sequence = input()
if sequence:
lines.append(str(sequence.upper()))
else:
break
return "\n".join(lines)
def all_caps_eof():
print("[CTRL+D] to Save & Generate Output")
lines = list()
while True:
try:
sequence = input()
except EOFError:
break
lines.append(str(sequence.upper()))
return "\n".join(lines)
def all_caps_readlines():
print("[CTRL+D] to Save & Generate Output")
lines = sys.stdin.readlines()
return f"\n\nALL CAPS:\n {' '.join(lines).upper()}"
# use single quotes w/ .join() when using it in fstring
if __name__ == "__main__":
print(all_caps_readlines())