Intro to Sets and Maps (USACO Guide Bronze)

Hello! I’m working on this problem from the USACO Guide (see this module: (https://usaco.guide/bronze/intro-sets?lang=py)

https://judge.yosupo.jp/problem/associative_array

It keeps saying “RE” but I can’t really figure out what is wrong with my code, could someone help me? Thank you so much!

a = {}
Q = int(intput())

for i in range(Q):
line = [int(i) for i in input().split()]
if line[0] == 0:
a[line[1]] = line[2]
else:
try:
print(a[line[1]])
except:
print(0)

Get rid of the try statement.

Also, please refer to this;

Formatting is not an issue for your current code, but it can get hard for longer programs.