Hi, this program is working atm but i suck at loops and such and im just wondering if there is any better way to do it, and if i do not enter a number in 1 of the 3 boxes when showing the results of the networks it just says "is not a valid mobile network", im wondering whats the best way to just show a blank if no number is entered thanks!

#imports easygui
import easygui

runprog = "yes"

#Set promts for multenterbox
promt = "Enter the mobile numbers"
title = "Moble number checker"

#Set lists for multenterbox fields
fields = ["First number", "Second number", "Third number"]
userInput = []

#Set list for networks
networks = ["083", "085", "086", "087"]


while runprog == "yes":

    #Get user inputs
    userInput = easygui.multenterbox(promt,title,fields)

    #Split user input list into variables

    no1 = userInput[0]
    no2 = userInput[1]
    no3 = userInput[2]


    Net1 = no1[0:3]
    Net2 = no2[0:3]
    Net3 = no3[0:3]


#Matches Userinput[0] with a network and displays what network it is on
    if Net1 == networks[0]:
        easygui.msgbox(no1 + "\t" "Is on the 3 Ireland network")
    elif Net1 == networks[1]:
        easygui.msgbox(no1 + "\t" "Is on the Meteor network")
    elif Net1 == networks[2]:
        easygui.msgbox(no1 + "\t" "Is on the 02 network")
    elif Net1 == networks[3]:
        easygui.msgbox(no1 + "\t" "Is on the Vodafone network")

    else:
        easygui.msgbox(no1 + "\t" "Is an invalid mobile network number")
            

#Matches Userinput[1] with a network and displays what network it is on
    if Net2 == networks[0]:
        easygui.msgbox(no2 + "\t" "Is on the 3 Ireland network")
    elif Net2 == networks[1]:
        easygui.msgbox(no2 + "\t" "Is on the Meteor network")
    elif Net2 == networks[2]:
        easygui.msgbox(no2 + "\t" "Is on the 02 network")
    elif Net2 == networks[3]:
        easygui.msgbox(no2 + "\t" "Is on the Vodafone network")

    else:
        easygui.msgbox(no2 + "\t" "Is an invalid network number")
            

#Matches Userinput[2] with a network and displays what network it is on
    if Net3 == networks[0]:
        easygui.msgbox(no3 + "\t" "Is on the 3 Ireland network")
    elif Net3 == networks[1]:
        easygui.msgbox(no3 + "\t" "Is on the Meteor network")
    elif Net3 == networks[2]:
        easygui.msgbox(no3 + "\t" "Is on the 02 network")
    elif Net3 == networks[3]:
        easygui.msgbox(no3 + "\t" "Is on the Vodafone network")

    else:
        easygui.msgbox(no3 + "\t" "Is an invalid network number")

#Ask user if they want to run the program again
    runprog = easygui.enterbox("Would you like to check more mobile numbers? yes/no")

python has default values google it.... set the default value if no values are entered to 0 or w.e

whats the best way to just show a blank if no number is entered

If no number is entered, the length would be zero.

import easygui

def check_numbers(number_entered, ctr):
    #Set list for networks
    networks = [ ["083", "3 Ireland"], ["085", "Meteor"], \
             ["086", "02"], ["087", "Vodafone"] ]

    if len(number_entered):     # some data was entered
        net = number_entered[0:3]
        found = 0
        for el in networks:
            if net == el[0]:
                easygui.msgbox("%s \t Is on the %s network" % \
                              (number_entered, el[1]))
                found = 1
        if not found:
            easygui.msgbox("%s\tIs an invalid mobile network number" % \
                           (number_entered))

    else:                               ## box is empty
        easygui.msgbox("No number entered for box %s" % (ctr))

runprog = "yes"

#Set promts for multenterbox
promt = "Enter the mobile numbers"
title = "Moble number checker"

#Set lists for multenterbox fields
fields = ["First number", "Second number", "Third number"]
userInput = []

while runprog.lower() == "yes":

    #Get user inputs
    userInput = easygui.multenterbox(promt,title,fields)

    #Split user input list into variables
    for ctr in range(3):
        check_numbers(userInput[ctr], ctr+1)

    #Ask user if they want to run the program again
    runprog = ""
    while runprog.lower() not in ["yes", "no"]:
        runprog = easygui.enterbox( \
                  "Would you like to check more mobile numbers? yes/no")

Line 8 should basically be same as

if number_entered

if number_entered is actually string (as there would be mix up between 0 and False if it were actually number). Notice that something, like generator does not need to be empty, but can produce values, even it has not length. So you must consider case by case what is best, len(something), something or something is None or something is False.

Small beauty point is that inside ( you need not put \ line continuation, like in line 5, 13, 17 and 45, it is implied by ().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.