x = “abcdef”
i = “i”
while i in x:
print(“i”, end=" ")
what is the role of end = " " here ?
x = “abcdef”
i = “i”
while i in x:
print(“i”, end=" ")
what is the role of end = " " here ?
Hello @dhingranaman07
Basically end is used in print function to change the functionality of print function after printing is done. By default once a print statement completes it ends with a new line. So to change it end is used.
In this code first of all the while loop will not run as there is no i letter present is string x but if i is present in it then it will be a infinite loop in which “i " is printed infinite times as first i is printed then rather than printing next i in next line it would be print just after a space as end=” ".
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.