while-loop 相关问题

while循环是在许多编程语言中使用的控制结构,只要满足特定条件,就连续执行一组指令。


使用JavaScript中的WALE循环在HTML上打印 我有一个作业,在尝试多种故障排除并向朋友寻求帮助后,我有些困惑。我没有得到教授的任何指导或帮助,所以这是非常重要的...

我尝试了几种不同的方法,尽管我和我的朋友都碰到了一个终点。我可以说,由于最初定义为“ 5”,因此newText变量正在忽略其余变量,但我不确定如何解决此问题。

回答 1 投票 0

为什么我的Python代码不会执行循环选择随机键单词?

import random #allows us to generate random numbers elsewhere in the code set1=[] # creates empty sets print("type genPassword() to initiate the program") def genPassword(): print("Answer the following questions in order. What is your first pet’s name? What is your favorite word? What was your first car? What city/town were you born in? What was the name of your first partner? dont forget to press enter after each word, no spaces.") for c in range(0,5): #allows the user to add elements to the list, each element has to be on a seperate line ele=input() set1.append(ele) print(set1)#displays the current set, currently used for debugging purposes, making sure the code works minlen=int(input("what is the minimum length you would like the password to be?: ")) maxlen=int(input("what is the max length you would like your password to be? (must be more than the shortest word you input in previous section): ")) passlen=0 while minlen >= passlen >= maxlen: set2=[] #empties set 2 amnt = random.randint (1,5) #selects a random number for the anount of keywords to use for f in range(0,amnt): keys=random.sample(set1,1) #selects a random key word set2.append(keys) #adds word to set 2 print(set2)#shows the words it chose set_amnt=len(set2) #how many words in the set iteration=0 string_len=0 for i in range(0,set_amnt): word_len=len(set2[iteration][0]) #takes the length of each word and adds it to the lenght of the whole string iteration=iteration+1 string_len=string_len+word_len print(string_len) #shows how long the string is (how many letters it is total) passlen=string_len

回答 1 投票 0



C++:执行一个while循环,直到按下键,例如ESC?

任何人都有一个不使用Windows.h的代码段。基本上是此代码,但不必使用Windows.h来做。我想在lin上使用它...

回答 5 投票 0


obrat | memb | TAB3。 |历史

回答 1 投票 0


列表列表中的唯一元素的创建列表[已关闭]

提出了类似的问题,但我无法理解答案。因此,我在这里需要一些帮助... 我有一个已排序的列表。 我需要修改此列表以包括Li ...

回答 1 投票 0




为了找到它,必须进行许多段循环的迭代?

考虑带有值的数组A,如图所示:

回答 1 投票 0

为什么在bash中,从字符串中删除领先和尾随的空格?

这是一个较大的bash脚本的MRE,它根据文件列表和字符映射替换文件名中的字符。而不是我要在两个“文件” fr ...的文件中读取的文件列表。

回答 1 投票 0

为什么在bash中sed sed在一段时间内从字符串中删除领先和尾随的空格

这是一个较大的bash脚本的MRE,它根据文件列表和字符映射替换文件名中的字符。而不是我要在两个“文件” fr ...的文件中读取的文件列表。

回答 1 投票 0





最新问题
© www.soinside.com 2019 - 2025. All rights reserved.