Predict the output of the Python code given below:
Text1="XYZ-456"
Text2=""
I=len(Text1)-1
while I>=0:
if Text1[I]>="0" and Text1[I]<="9" :
Val=int(Text1[I])
Val=Val*2
Text2=Text2+str(Val)
elif Text1[I]>="A" and Text1[I]<="Z" :
Text2= Text2+(Text1[I-1])
else:
Text2=Text2+"*"
I-=1
print (Text2)
Answer:
Answer by student
The output of the Python code is 12108*YX6 .
Detailed answer by teachoo
The rest of the post is locked. Join Teachoo Black to see the full post.