我的项目目前只是在列表中打印出不同字符串值的列表。每当用户在输入提示时键入“enter”时,for循环就会迭代并且假设显示他们输入的不同顺序。出于某种原因,在第一次输入输入后输入enter,它不会不显示清单。我基本上只想要将列表重新排序5次然后循环一起停止。这是代码,希望能够清楚地知道我正在尝试做什么。
import random
print('\t\t\tHOWDY! This is my go to for the homework. Give it a shot and let me know what you guys think')
print('\n\n\tRight down below is an input that will prompt you guys to add in about 5 different words. After that, it will print off different orders of this program 5 times.')
random_stuff = ''
length = 0
while not random_stuff:
random_stuff = input('\nPlease add in a word to start: ')
input('\nPress enter to continue')
random_stuff = random_stuff.split()
print('\nNow lets add in 4 more words')
while len(random_stuff) < 5:
random_stuff.append(input('\nPlease input a new phrase: '))
print('\nOkay so here is your list in the order it was received.')
input('\nPress enter to continue')
for x in range(len(random_stuff)):
print(random_stuff[x], end=' ')
print('\nNow lets see it in a random order. Please type in enter when prompted by the command. This will be done 5 times')
while length < 5:
press_enter =input('\nType enter to see what happens: ')
press_enter = press_enter.lower()
if press_enter == 'enter' and length < 5:
for x in range(len(random_stuff)):
random_order = random.randrange(len(random_stuff))
print(random_stuff[random_order], end=' ')
del(random_stuff[random_order])
length += 1