dimanche 12 février 2017

Why is my code printing more than once?

Vote count: 0

number = raw_input("Please enter the fixture number: ")
    myfile = open('file.txt')
    for line in myfile:
        item = line.split(',')
        if item[0] == number:
            title = '{0:20} {1:20} {2:20} {3:20} {4:20} {5:20}'.format('Fixture number', 'date', 'nickname1', 'nickname2', 'Fixture Played', 'Winning Nickname')
            print(title)
            result = '{0:20} {1:20} {2:20} {3:20} {4:20} {5:20}'.format(item[0],item[1],item[3],item[4],item[5],item[6])
            print(result)
        elif item[0] != number:
            print("not exist")

Hi there I am new with python, so recently I encountered a problem my

elif item[0] != number:

is printing "not exist" for the amount of lines in my file how do I get it to print only once if it is wrong?

asked 34 secs ago

Let's block ads! (Why?)



Why is my code printing more than once?

Aucun commentaire:

Enregistrer un commentaire