Python:遍历嵌套的for循环吗?

时间:2020-10-09 01:20:39

标签: python-3.x for-loop

我的代码是

string password;
cout << "Password: "; 
cin >> password; 

我的输出是:

num_list = [1, 2, 3]
alpha_list = ['a', 'b', 'c']

for number in num_list:
    print(number)
    for letter in alpha_list:
        print(letter)

但是我想要这样的输出:

Output
1
a
b
c
2
a
b
c
3
a
b
c

我如何遍历嵌套的for循环以获得上述输出?

1 个答案:

答案 0 :(得分:0)

您可以为此使用Obj_Size$new_col <- mapply(function(x, y) toString(setdiff(x, y)), Obj_Size$colnames, c(NA, Obj_Size$colnames[-nrow(Obj_Size)]))

zip