「宝くじ Python3編」回答
123456[1:3] で 12 が出てくる
654321[-3:-1] で 32 が出てくる
654321[-3:] で 321 が出てくる
参考:
note.nkmk.me
# coding: utf-8 # Your code here! hit = input() num = int(input()) for i in range(num): each = input() if hit == each: print("first") elif (int(hit)-1 == int(each)) or (int(hit)+1 == int(each)): print("adjacent") elif hit[-4:] == each[-4:]: print("second") elif hit[-3:] == each[-3:]: print("third") else: print("blank")