0
Can we use else statement without an if condition in c similar to python
11 ответов
+ 3
We can write an equivalent if we knew the use case. In python, the else is useful if we are using a while loop as sort of a look up function. If the value we are looking for is not found, we can run an else to maybe notify the user. If it is found, we can break the loop so the else is never run. This is easily done in C by simply using a flag "isFound" or by loading the found entry into a veriable for further work.
+ 5
else in python (except with if...) can be used with:
▪︎for ... loop
▪︎while ... loop
▪︎try ... except ...
+ 4
Python's while/else and for/else statements are unique to Python. You won't find anything like them in C.
+ 3
No, where in python have you seen that?
+ 2
In few iterable cases we can run else statement without if after 'for' or after 'while' inorder to indicate the end of iterations
+ 1
No, first of all, you have to understand what is where is used else statement, he is use case if boolean result is False, then, in Python or C, then if else is first than if, it would gives a syntax error
+ 1
I guess the simple answer is no, you can't
+ 1
Okay thank you all
0
In python...
0
I don't think so. What cases?
0
Thank you Kail for your valuable answere