cont.....
Of Python #2-Tuples and List In Python
Of Python #2-Tuples and List In Python
what is For Loop ?
A statement which makes the code to executed repeatedly.
Unlike in C, C++, Java For looping has the same syntax, but in Python its Different.
Syntax:
for TemporaryVariableName in ActualVariableName :
statement
Example:
values=['value1', 'value2', 'value3']
for value in values:
print value
Ouput:
Value1
Value2
Valus3
Note Worthy: for statement should have : at the end of the line in python eg: for(condition):
_____________________________________________________________
Don't forget to Try it!
_____________________________________________________________
What is while Loop?
A statement which makes the code to executed repeatedly as of the repeated if statement
Unlike in C, C++, Java While looping has the same syntax , but in Python its with Slight Different.
Syntax:
while (condtion) :
statement
Example:
Value=0
while (value<10):
print (value)
value = value+1
Output:
0
1
2
3
4
5
6
7
8
9
Note Worthy: while statement should have : at the end off the line in python
eg: while(condition):
NEXT POST:
Python #4-If and elif statements in Python
eg: while(condition):
NEXT POST:
Python #4-If and elif statements in Python
Thanks and Regards,
Tech Bird
Comments