pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Python pastebin - collaborative debugging tool View Help


Posted by tom on Thu 28 May 02:30
report abuse | View followups from tom | download | new post

  1. #!/usr/bin/env python3
  2.  
  3. import sys
  4. import random
  5.  
  6. articles = ["the", "his", "her", "somebody's", "nobody's", "a"]
  7. subjects = ["cat", "hat", "flamingo", "bear", "turd", "belt"]
  8. verbs = ["cried", "laughed", "ran", "melted", "jumped", "ate"]
  9. adverbs = ["loudly", "sadly", "quietly", "mightily", "haughtily", "badly"]
  10. structures = [(articles, subjects, verbs, adverbs), (articles, subjects, verbs)]
  11.  
  12. lines = 5
  13.  
  14. while True:
  15.     try:
  16.         line = input("Enter a number between 1 and 10: ")
  17.         number = int(line)
  18.            
  19.         if 1 <= number <= 10:
  20.             lines = number
  21.  
  22.         break
  23.     except ValueError as err:
  24.         print(err)
  25.         continue
  26.  
  27. while lines:
  28.     poem = ""
  29.     for content in structures[random.randint(0,1)]:
  30.         poem += random.choice(content) + " "
  31.     print(poem)
  32.     lines-=1

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post