I would like to make a selection menue for 2 programs that i have. A menu similar to the one below.
import sys
print """Menu
1) Random
2) Search"""
answer = raw_input("Make a selection> ")
if "1" in answer: print "This will contain program 1"
elif "2" in answer: print "This will contain program 2"
Program 1
import re
data = ["1. Principle of Segmentation: \n a) Divide an object into independent parts \n - Replace a large truck by a truck and trailer. \n - Use a work breakdown structure for a large project \n - Multiple Engine on Plane \n b) Make an object easy to disassemble \n - Bicycle disassembling (saddle, wheels) \n - Furniture (sofas, table) \n - Crib \n c) Increase the degree of fragmentation or segmentation \n - Replace solid shades with Venetian blinds \n - Computer covers with holes for ventilation \n - Multi blade cartridge Razor \n",
"2. Principle of Local Quality: \n a) car If a structure of an object (or its environment, or external force) \n is uniform, make it non-uniform \n - Moulded hand grips on tools \n - Drink cans shaped to facilitate stable stacking \n b) Reconstruct an object so that different parts perform different functions \n -Hair dryer (heating and cooling) \n -Hammer with nail puller \n -Pencil with eraser \n c) Establish the most suitable operation conditions for every component of \n an object \n - Lunch box with special compartments for hot and cold \n - Freezer compartment in refrigerator \n ",
"3. Principle of Asymmetry: \n a) If an object is symmetrical, change its shape to irregular \n -Asymmetric paddles mix \n - cement truck \n - blender \n - cake mixer \n b) If an object is already of irregular shape, \n increase the degree of its asymmetry \n - Asymmetric scissors are easier to use then symmetric ones \n - Introduction of several different measurement scales on a ruler"]
for subtext in data:
if re.search(r"\engine\b", subtext, re.I):
print "FOUND", subtext
Program 2
import random
import time
raw_input("\n Random Search, press Enter \n")
def points():
results = ["\n 1. Principle of Segmentation: \n a)Divide an object into independent parts \n - Replace a large truck by a truck and trailer \n - Gator-grip socket spanner \n - Multi-engined aircraft \n b)Make an object easy to disassemble \n - Bicycle disassembling (saddle, wheels) \n - Furniture (sofas, table) \n - Crib \n c)Increase the degree of fragmentation or segmentation \n - Replace solid shades with Venetian blinds \n - Computer covers with holes for ventilation \n - Multi blade cartridge Razor",
"\n 3. Principle of Local Quality: \n a)If a structure of an object (or its environment, or external force) is uneven make it even \n - Moulded hand grips on tools \n - Drink cans shaped to facilitate stable stacking \n b)Reconstruct an object so that different parts perform different functions \n - Hair dryer (heating and cooling) \n - Hammer with nail puller \n - Pencil with eraser \n c)Establish the most suitable operation \n conditions for every component of an object \n - Lunch box with special compartments for hot and cold \n Freezer compartment in refrigerator",
"\n 4. Principle of Asymmetry: \n a)If an object is symmetrical, change its shape to irregular \n - Asymmetric paddles mix \n - cement truck \n - blender \n - cake mixer \n b)If an object is already of irregular shape \n increase the degree of its asymmetry \n - Asymmetric scissors are easier to use then symmetric ones \n - Introduction of several different measurement scales on a ruler",
"\n 5. Principle of Combination: \n a)Combine like objects or objects intended for similar or related operations \n - Combine computers on a network \n - Fragile and weak components, such as glass plates can be made stronger \n without increasing weight by combining them to packages",
"\n 6. Principle of University: \n a)Design an object to perform multiple functions \n so that some other objects are no longer needed \n - Use a single adjustable wrench for all nuts \n - Team leader can act a recorder and time keeper \n - Toothbrush with dental floss"]
rand1 = random.choice(results)
rand2 = random.choice(results)
rand3 = random.choice(results)
time.sleep(1)
print rand1
time.sleep(1.5)
print rand2
time.sleep(2)
print rand3
time.sleep(1)
loop = 1
while loop == 1:
points()
z = raw_input("\nWere the hints Helpfull?")
if z == "no":
continue
else:
loop = 0
Program 1 Searches for the word in the Principle and Program 2 generates by random. I tried combining them into the menue so the user can chose which program they would like to run but i keep getting errors.
Any Help will be appreciated.
Thank you.