Soujanya_2 0 Newbie Poster
    import sys
    slayer=int(input("enter your guess for SLAYERS:"))
    count_letters=len(str(slayer))
    if count_letters!=6:
        print('Your guess is incorrect: SLAYER must be a 6-digit number. ')
    else:
        new_slayer=3*slayer
        i=1
        while(i<=1000):
        a=[]
        a=str((slayer//i)%10)
        i=i*10
        layers=a[1]*100000+a[2]*10000+a[3]*1000+a[4]*100+a[5]*10+a[0]*1
    if new_slayer==layers:
        print('Your guess is correct: ')
        print('SLAYER+SLAYER+SLAYER=',new_slayer)
        print('LAYERS=',layers)
    else:
        print('Your guess is incorrect: ')
        print('SLAYER+SLAYER+SLAYER=',new_slayer)
        print('LAYERS=',layers)

I want to store the results of modulo into array and later use to do layers=a[1]100000+a[2]10000+a[3]1000+a[4]100+a[5]10+a[0]1 to get the number. Suppose SLAYER is 142857,SLAYER+SLAYER+SLAYER=LAYERS so to find LAYERS number i applied above formula. But i am getting "string index out of error". please solve this issue for me. I am new to python3!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.