已知元组tuple = ('h','a','p','p','y',['E','D','I','N','G']),请向元组的最后一个列表元素中添加新元素'N',组成happyENDING,并将所有小写字母转换为大写字母。要求:输出结果为:H A P P Y ['E', 'N', 'D', 'I', 'N', 'G'] (10分)
这个是硬刚 tuple 呀, 不知道有啥意义。
tuple = ('h','a','p','p','y',['E','D','I','N','G'])
tuple[-1].insert(1,'N')
for x in tuple:
if type(x) == list:
print(x, end=" ")
else:
print(x.upper(), end=" ")
t = ('h', 'a', 'p', 'p', 'y', ['E', 'D', 'I', 'N', 'G'])
t[5].insert(1, "N")
for i in t:
print(str(i).upper(), end = ' ')