原题:CCC '19 J2 - Time to Decompress
input:
4
9 +
3 -
12 A
2 X
output:
+++++++++
---
AAAAAAAAAAAA
XX
#answer
L=int(input())
for _ in range(L):
vals=input().split()
N=int(vals[0])#why this works?
ch=vals[1]
print(ch*N)
question: 我认为【0】对应第一位数,那如果input两位数比如12,不就完蛋了吗?
run result: good
猜想:list slice 和string slice 不同
求证:正确。After split turn input into list, the [0] means the first term in list
Exm: >>>list=[1,2,3,4]
>>>print(list[0])
result: 1
supplement:
#list and slice 1:how to replace specific items in the list(space and more numbers are the same
numbers=[1,2,3,4]
numbers[1:3]=[8,9]
print(numbers)#[1,8,9,4]
#list and slice 2:how to replace numbers in items with string
numbers2=[1,2,3,4]
numbers2[1:3]='wat?'
print(numbers2)#[1,'w','a','t','?',4]
#"Introducing python P102