mercredi 11 novembre 2020

How to create an if statement condition that would accept the list of variables?

How to create a condition in the if statement that would accept list of variables and print out the numbers that is divisible by 5?`

firstNumber = input("Write the First Number: ")
secondNumber = input("Write the Second Number: ")
thirdNumber = input("Write the the Third Number: ")
fourthNumber = input("Write the the Fourth Number: ")
list1 = [firstNumber, secondNumber, thirdNumber, fourthNumber]

def divisibleByFive():
    for x in list1:
        if x%5 == 0:
            print(x)

divisibleByFive()

Aucun commentaire:

Enregistrer un commentaire