Concatenate Two Lists
Python
Easy
3 views
Problem Description
Read two lists A and B. Output concatenated list A followed by B.
Input Format
Line1 n. Line2 n ints. Line3 m. Line4 m ints.
Output Format
One line concatenated.
Official Solution
import sys
lines=sys.stdin.read().splitlines()
if len(lines)<4: sys.exit(0)
i=0
n=int(lines[i].strip()); i+=1
A=lines[i].split()[:n]; i+=1
m=int(lines[i].strip()); i+=1
B=lines[i].split()[:m] if i<len(lines) else []
out=A+B
sys.stdout.write(' '.join(out))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!