by D01phin, bj,20150818
"Title:" Creates a program that can display a group of words in a random order. Ask the program to print out all the words, but not repeat!
# coding=utf-8# Random Show Word # # by d01phin,bj,20150818 # # Function:1, RA Ndom Show Words # 2, show all words and no repeat # #--------------------------------------------#im Port Randomword = ["Dolphin", "Angel", "Computer", "hacker", "Information", "program"]same = wordfor i in range (0,6): show = R Andom.choice (same) print (show) same.remove (show) input ("\nhey,man! You got it! ")
This program's The flaw is : The number of times in the loop, depending on the number of words you enter in Word to modify, originally wrote a can dynamically modify the number of cycles, but there are always problems in debugging, Always executed three times (execution times: number of words/2), then no longer executed, I hope the great God can come out to answer, I will post the source code.
# coding=utf-8#--------------------------------------------## random show word ## By D01phin,BJ,20150818 ## Function: 1, random show words ## 2, Show all words and no repeat ##--------------------------------------------#import randomword = ["Dolphin", "Angel", "Computer", "hacker", "Information", "program", "Hello", "iphone"]same = wordfor i in word:show = random.choice (same) print (show) same.remove (show) input (" \nhey,man! you got it ! ")
This article is from the "Siberian Wolf 026" blog, make sure to keep this source http://1429223.blog.51cto.com/1419223/1688125
Python practice randomly displays non-repeating words