-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathsampleMethodsInput.py
More file actions
37 lines (31 loc) · 894 Bytes
/
sampleMethodsInput.py
File metadata and controls
37 lines (31 loc) · 894 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
31
32
33
34
35
36
37
# Example input:
# 5
# 1 2 3 4 5
# Example Output: n = 5, data = [1, 2, 3, 4, 5]
n, data = input(), [int(i) for i in input().strip().split()]
# How to take input from multiple lines
# Will take input until sees a blank line (sentinel)
# Example input:
# 1 2 3
# 4 5
# Example Output: user_input = '1 2 3 4 5'
sentinel = ''
user_input = '\n'.join(iter(input, sentinel)).replace('\n', ' ')
# Example input:
# 1 2 3 4
# Example Output: var1 = 1, var2 = 2, var3 = 3, var4 = 4, such that var1, var2, var3, var4 are of type string
var1, var2, var3, var4 = input().split()
# Example input:
# 1 2 3 4
# Example Output: var1 = 1, var2 = 2, var3 = 3, var4 = 4, such that var1, var2, var3, var4 are of type int
var1, var2, var3, var4 = map(int, input().split())
# Example input:
# 1 2 3
# 1 2 3
# ...
# 1 2 3
while True:
try:
var1, var2, var3 = map(int, input().split())
except EOFError:
break