Jan-11-2021, 10:11 AM
Hello everyone, I hope you are having a great day.
Here's a simple question.
I have a list of numbers:
If they are all >= 5, say "You are good to go!"
If it contains numbers < 5, say "You have some invalid numbers" AND they are: [3, 1, 2] (or in any other format)
So far I can handle both situations separately:
Here's a simple question.
I have a list of numbers:
numbersList = [6, 3, 9, 36, 96, 1, 18, 99, 8, 5, 12, 2]I want an output like this:
If they are all >= 5, say "You are good to go!"
If it contains numbers < 5, say "You have some invalid numbers" AND they are: [3, 1, 2] (or in any other format)
So far I can handle both situations separately:
for i in numbersList: if i < 5: print("You have some invalid numbers.") break else: print("You are good to go.")and
invalidNumbers = [] for i in numbersList: if i < 5: invalidNumbers.append(i) print(invalidNumbers)But I'm having trouble mixing the two together.
