我有一个包含四种颜色的列表,我想生成一个无限列表,这样当我输入随机索引时,它会显示在该位置找到的颜色
number = int(input('write your index here:')) color = ['b','k','g','y'] chosen_color = color[number%len(color)] print(chosen_color)
输出:
write your index here: 98435164 b