dimanche 21 avril 2019

python3 - if loop for bubblesort algorithm

So I'm having a little trouble with my code and i'm 99% sure it's my 'if/elif' loop. I have the txt files imported and my bubblesort algorithm working but whatever the input it will only print 'array1' of 3.

    examplearray=(input('Select Array'))
    if examplearray == 'ex1' or 'ex1'.upper():
        bubbleSort(ex1array)
        print(ex1array)
    elif examplearray == 'ex2' or 'ex2'.upper():
        bubbleSort(ex2array)
        print(ex2array)
    elif examplearray == 'ex3' or 'ex3'.upper():
        bubbleSort(ex3array)
        print(ex3array)

anyone have any pointers for this please? just ask if you need anymore of my code; thanks in advance.

Aucun commentaire:

Enregistrer un commentaire