Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions sampleMethodsInput.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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