What is wrong with this enigma machine in python?
<p>I got set and set myself the challenge of making an enigma machine and this is what I have done so far I have de-bugged it and corrected it. The thing is the code is massive and it doesn't run correctly. For it comes up with an error. (i have got it working yet not working  properly. It should know run properly yet it doesn't) 
How can I make this code shorter? (so i can still learn in the process)
What is the problem with the code making it not run?</p>

<p>Context: Enigma machine works with wheels which it turn each time it is used for the first wheel when the first wheel has done a full rotation it goes back to the beginning and the second wheel does one turn. so on and so forth for 5 wheels. 
(note this code doesn't have the fixed positions at the end nor the one's you can change at the end of the code)</p>

<pre><code>import collections
import sys

wh1=input('wheel 1')
wh2=input('wheel 2')
wh3=input('wheel 3')
wh4=input('wheel 4')
wh5=input('wheel 5')
print'then enter the first letter'
theinput=raw_input('enter letter')
 # wheel 1
x=wh1

# wheel 2
y=[0] # the append list 
yy=wh2 # the value of rotation

# wheel 3
z=[0]
zz=wh3

# wheel 4
w=[0]
ww=wh4

# wheel 5
s=[0]
ss=wh5

# the values that are rotated
# note to add wh4ch to 5 to allow there to one for each wheel
wh1ch = collections.deque(['b','e','d','c','a'])
wh2ch = collections.deque(['d','a','b','e','c'])
wh3ch = collections.deque(['e','a','b','d','c'])
wh4ch = collections.deque(['a','b','c','d','e'])
wh5ch = collections.deque(['e','d','c','b','a'])




# check1
if x&gt;5:
    y.append(1)
    yy=y.count(1)
    x=0
# check2
if y&gt;5:
    z.append(1)
    zz=z.count(1)
    y=0
# check3
if z&gt;5:
    w.append(1)
    ww=w.count(1)
    z=0
#check4
if w&gt;5:
    s.append(1)
    ss=s.count(1)
    w=0
#check5    
if s&gt;5:
    s=0













# wheel 1

if theinput == 'a':
    value=wh1ch[0]
    wh1ch.rotate(x)
    x= x+1

if theinput == 'b':
    value=wh1ch[1]
    wh1ch.rotate(x)
    x= x+1


if theinput == 'c':
    value=wh1ch[2]
    wh1ch.rotate(x)
    x= x+1

if theinput == 'd':
    value=wh1ch[3]
    wh1ch.rotate(x)
    x= x+1


if theinput == 'e':
    value=wh1ch[4]
    wh1ch.rotate(x)
    x= x+1
# check1
if x&gt;5:
    y.append(1)
    yy=y.count(1)
    x=0
# check2
if y&gt;5:
    z.append(1)
    zz=z.count(1)
    y=0
# check3
if z&gt;5:
    w.append(1)
    ww=w.count(1)
    z=0
#check4
if w&gt;5:
    s.append(1)
    ss=s.count(1)
    w=0
#check5    
if s&gt;5:
    s=0




# wheel 2

if value == 'a':
    value=wh2ch[0]
    wh2ch.rotate(y[0])
    x= x+1

if value == 'b':
    value=wh2ch[1]
    wh2ch.rotate(y[0])
    x= x+1


if value == 'c':
    value=wh2ch[2]
    wh2ch.rotate(y[0])
    x= x+1

if value == 'd':
    value=wh2ch[3]
    wh2ch.rotate(y[0])
    x= x+1


if value == 'e':
    value=wh2ch[4]
    wh2ch.rotate(y[0])
    x= x+1
# check1
if x&gt;5:
    y.append(1)
    yy=y.count(1)
    x=0
# check2
if y&gt;5:
    z.append(1)
    zz=z.count(1)
    y=0
# check3
if z&gt;5:
    w.append(1)
    ww=w.count(1)
    z=0
#check4
if w&gt;5:
    s.append(1)
    ss=s.count(1)
    w=0
#check5    
if s&gt;5:
    s=0
# wheel 3

if value == 'a':
    value=wh3ch[0]
    wh3ch.rotate(z[0])
    x= x+1

if value == 'b':
    value=wh3ch[1]
    wh3ch.rotate(z[0])
    x= x+1


if value == 'c':
    value=wh3ch[2]
    wh3ch.rotate(z[0])
    x= x+1

if value == 'd':
    value=wh3ch[3]
    wh3ch.rotate(z[0])
    x= x+1


if value == 'e':
    value=wh3ch[4]
    wh3ch.rotate(z[0])
    x= x+1

# check1
if x&gt;5:
    y.append(1)
    yy=y.count(1)
    x=0
# check2
if y&gt;5:
    z.append(1)
    zz=z.count(1)
    y=0
# check3
if z&gt;5:
    w.append(1)
    ww=w.count(1)
    z=0
#check4
if w&gt;5:
    s.append(1)
    ss=s.count(1)
    w=0
#check5    
if s&gt;5:
    s=0


#wheel4

if value == 'a':
    value=wh4ch[0]
    wh4ch.rotate(w[0])
    x= x+1

if value == 'b':
    value=wh4ch[1]
    wh4ch.rotate(w[0])
    x= x+1


if value == 'c':
    value=wh4ch[2]
    wh4ch.rotate(w[0])
    x= x+1

if value == 'd':
    value=wh4ch[3]
    wh4ch.rotate(w[0])
    x= x+1


if value == 'e':
    value=wh4ch[4]
    wh4ch.rotate(w[0])
    x= x+1

# check1
if x&gt;5:
    y.append(1)
    yy=y.count(1)
    x=0
# check2
if y&gt;5:
    z.append(1)
    zz=z.count(1)
    y=0
# check3
if z&gt;5:
    w.append(1)
    ww=w.count(1)
    z=0
#check4
if w&gt;5:
    s.append(1)
    ss=s.count(1)
    w=0
#check5    
if s&gt;5:
    s=0


# wheel 5

if value == 'a':
    value=wh5ch[0]
    wh5ch.rotate(s[0])
    x= x+1

if value == 'b':
    value=wh5ch[1]
    wh5ch.rotate(s[0])
    x= x+1


if value == 'c':
    value=wh5ch[2]
    wh5ch.rotate(s[0])
    x= x+1

if value == 'd':
    value=wh5ch[3]
    wh5ch.rotate(s[0])
    x= x+1


if value == 'e':
    value=wh5ch[4]
    wh5ch.rotate(s[0])
    x= x+1

# check1
if x&gt;5:
    y.append(1)
    yy=y.count(1)
    x=0
# check2
if y&gt;5:
    z.append(1)
    zz=z.count(1)
    y=0
# check3
if z&gt;5:
    w.append(1)
    ww=w.count(1)
    z=0
#check4
if w&gt;5:
    s.append(1)
    ss=s.count(1)
    w=0
#check5    
if s&gt;5:
        s=0
#got to run a check function to equal out x in sections to make it neat do ( def check:
    # check functions for each list and lable the with hash #

    # do that for everything to make it neat 

print
print
print value
print 'these are the order of rotation of the coords of the wheels'
print x
print yy
print zz
print ww
print ss
</code></pre>
