python_test_12

  1. 比较:a=[1,2,3]和b=[(1),(2),(3)] 以及c=[(1,),(2,),(3,)]的区别

    a=[1,2,3]            是列表
    b=[(1),(2),(3)]      是列表
    c=[(1,),(2,),(3,)]   是元组列表
    
  2. 两个列表colors = [“balck”,“white”] sizes=[“S”,“M”,“L”],请严格按照顺序输出如下结果:
    [(“balck”,“S”),(“white”,“S”),(“balck”,“M”),(“white”,“M”),(“balck”,“L”),(“white”,“L”)]

    colors = ["balck", "white"]
    sizes = ["S", "M", "L"]
    my_list = list()
    for i in sizes:
        for k in colors:
            my_list.append([k, i])
    print(my_list)
    

猜你喜欢

转载自blog.csdn.net/weixin_44786482/article/details/89045007