lundi 3 décembre 2018

Using if-else within for loop

marks = [10, 20, 70, 81, 14, 78, 5, 95] for i in marks: if i < 40: print('You have failed and secured {} marks'.format (i)) else: print("You passed with {} marks".format (i))

OUTPUT:: You have failed and secured 10 marks You have failed and secured 20 marks You have failed and secured 14 marks You have failed and secured 5 marks You passed with 95 marks

How to use else within for loop as it is executed after for loop?

Aucun commentaire:

Enregistrer un commentaire