Oct-29-2019, 11:53 AM
Hi everyoine,
I had a doubt about for range in Python when I also use string length or array, for example:
Regards,
RavCoder
I had a doubt about for range in Python when I also use string length or array, for example:
def name(s): l = s.split() for i in range(len(l)-1): s = l[i] print(s) s ="mohandas karamchand gandhi" print(name(s)) output : mohandas karamchand None
def name(s): l = s.split() for i in range(len(l)+1): s = l[i] print(s) s ="mohandas karamchand gandhi" print(name(s)) output : mohandas karamchand gandhiWhy if I change the operator in Len (s) [ + / - ] 1, does it give me different results?
Regards,
RavCoder