Can any explain me how end='' works here | SoloLearn: Learn to code for FREE!

+1

Can any explain me how end='' works here

def rev_str(my_str): length = len(my_str) for i in range(1,length): yield my_str[i] # For loop to reverse the string for char in rev_str("hello"): print(char, end= '') print() # Output: olleh

5/7/2020 6:41:04 AM

Fanatic

2 Answers

New Answer

+4

The end='' is used to remove the default line break of the print function. Example : for i in range(4): print(i) Output : 0 1 2 3 And if you do : print(i, end='') Output : 0123 Hope this helps :))

0

Arb Rahim Badsa thanx