On Tue, Oct 23, 2012 at 7:48 PM, Alexander <rhettna...@gmail.com> wrote: > On Tue, Oct 23, 2012 at 7:24 PM, Nitin Ainani <nitinain...@gmail.com> wrote: >> Dear Sir/Madam, >> >> I am new to python I have a question. It is as follows: >> >> Suppose s is a variable and s stores empty string >> >> emptyString = "" > #consider the string to be non-empty, that is, let's say 13 characters > long (the number you chose below) > string13 = "1234567890ABC" > print ( string13 [ 0 ] ) > >>Now if we write following statement >> >> print ( s [ 0 ] ) # it gives error
It should say print (string13 [ 0 ]) in python 3 > ***what error? *** > The error and your example can be used to understand indexes. > s [ 0 ] is asking for the value of a specific piece of s. > s[0] is asking for the value at index Zero of string s. > S has nothing inside of it. > >> >> print(s[0:]) # it does not give error > #what does it give? >> print (s[13:13]) # this too does not give error > #What is the output >> why? > Did you at any point use s = {}? -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor