I need to skip the data using continue while using for loop
def skip_data(i):
if i == 5:
continue
else:
print(i)
for i in range(0,10):
skip_data(i)
I need to skip the data using continue while using for loop
def skip_data(i):
if i == 5:
continue
else:
print(i)
for i in range(0,10):
skip_data(i)
continue is a keyword used inside loops. Since, you have not used it inside a loop it gives you an error.
You can either just use return instead of continue or if you know specific data that you need to skip for example in this case you need to skip 5 you can do something like this :-
def skip_data(i):
if i != 5:
print(i)
for i in range(0,10):
skip_data(i)