如何实现while循环python的不同结果
问题是,当n>数据集的长度时,我想提示另一条消息,然后是“正确的登录信息,欢迎回来”。但是,如果数据集[n]=accounts2,我确实希望它提示该消息。我该怎么办?您只需在while循环中添加另一条if语句即可如何实现while循环python的不同结果,python,while-loop,Python,While Loop,问题是,当n>数据集的长度时,我想提示另一条消息,然后是“正确的登录信息,欢迎回来”。但是,如果数据集[n]=accounts2,我确实希望它提示该消息。我该怎么办?您只需在while循环中添加另一条if语句即可 n = -1 while not dataset[n] == accounts2: n = n+1 if dataset[n] == accounts2 or n > len(dataset): print('correct login information,
n = -1
while not dataset[n] == accounts2:
n = n+1
if dataset[n] == accounts2 or n > len(dataset):
print('correct login information, welcome back.')
我根本不会使用
while
循环
if (n > len(dataset[n])):
# do something
else:
print('correct login information, welcome back.')
if all(x == accounts2 for x in dataset):
print('correct login information')