Hi guys i wonder if someone can help an absolute noob out with some homework.
i was given a brief of:
ask a user to input up to 3 mobile numbers.
for the numbers entered display the list of numbers entered and clearly displays the mobile network each number belongs to alongside,your program should also indicate if a number inputted does not belong to a mobile network .
using the following parameters :
prefix network
o83 3ireland
085 meteor
086 o2
087 vodafone
so far i have :
from easygui import *
# create varible to say if program runs or not
run = "yes"
#while loop to keep program running
while run == "yes":
#create list to hold prefix values
networkList = ["087","086","085","083"]
#set prompt,title and fields
prompt = "please enter your phone numbers "
title = "checks which Irish phone network you are using "
fields = ["phone number 1 ","phone number 2 ","phone number 3 "]
#get user input
userInput =[]
userInput = multenterbox(prompt,title,fields)
#assign variables to input
userInput1=userInput[0]
userInput2=userInput[1]
userInput3=userInput[2]
inputList=[userInput1,userInput2,userInput3]
#slice prefix for comparison to list
prefix1=userInput1[:3]
prefix2=userInput2[:3]
prefix3=userInput3[:3]
#set title for output message
title="your results "
msg="\n"+userInput1+ "\t"+ userInput2 +"\t"+userInput3
if prefix1==networkList[0] or prefix2==networkList[0] or prefix3==networkList[0]:
msg+= "\n"+" vodafone ""\t"
if prefix1==networkList[1] or prefix2==networkList[1] or prefix3==networkList[1]:
msg+= " o2 "+"\t"
if prefix1==networkList[2] or prefix2==networkList[2] or prefix3==networkList[2]:
msg+= " meteor "+"\t"
if prefix1==networkList[3] or prefix2==networkList[3] or prefix3==networkList[3]:
msg+="\t"+" 3Ireland "+"\t"
#run again ?
msg+="\n""would you like to run this program again? "
run= buttonbox(msg,title,choices=["yes","no"])
no = msgbox("\n""goodbye")
while it seems to work ...there is an issue with the layout and some of the numbers dont match up with the network name.
can any one steer me in the right direction before my head go boom ?
also there must be a more elegant way of coding this ...is there ?
pleases and thank yous included :)