You Can Be Done This By using COMMA (,) Operator.
The Syntax for this like
for var_name in list_name :
print var_name,
if list contain elements from 1 to 7 (ie list= [1,2,3,4,5,6,7]),if we print the list normally without using comma operator which will produce a new line each time,
ie,
list=[1,2,3,4,5,6,7]
for item in list :
print item
will produce an output
1
2
3
4
5
6
7
but if we will use comma operator,
ie,
for item in list :
print item,
we will get an output like
1 2 3 4 5 6 7
for any query regarding coding comment below
HAPPY CODDING

No comments:
Post a Comment