Python practice randomly displays non-repeating words

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.