Issue
I'm trying to copy the characters entered by the user to an empty string. If the user enters 'xt'
, it will terminate. Here is what I have done:
z=raw_input("ent")
d=''
for j in range(len(z)):
d+=z[j]
if(d=="xt"):
break
However, I get an error.
IndexError: string index out of range
Solution
Try looping through the string itself:
z=raw_input("ent")
d=''
for j in z:
d+=j
if d=="xt":
break
Answered By - rassar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.