vendredi 4 novembre 2016

Error in my python cipher

I'm using the code

a = 1
b = 2
c = 3
d = 4
e = 5
f = 6
g = 7
h = 8
i = 9
j = 10
k = 11
l = 12
m = 13
n = 14
o = 15
p = 16
q = 17
r = 18
s = 19
t = 20
u = 21
v = 22
w = 23
x = 24
y = 25
z = 26
fullstring = raw_input('Cipher-thing:')
if fullstring.isalpha and len(fullstring) > 0:
    fullstring[0] = (fullstring[0] * pow(len(fullstring)) / len(fullstring)
if len(fullstring) >= 1:
    fullstring[1] = (fullstring[1]^len(fullstring))/len(fullstring)
if len(fullstring) >= 2:
    fullstring[2] = (fullstring[2]^len(fullstring))/len(fullstring) 
if len(fullstring) >= 3:
    fullstring[3] = (fullstring[3]^len(fullstring))/len(fullstring)
if len(fullstring) >= 4:
    fullstring[4] = (fullstring[4]^len(fullstring))/(fullstring)
if len(fullstring) >= 5:
    fullstring[5] = (fullstring[5]^len(fullstring))/len(fullstring)
if len(fullstring) >= 6:
    fullstring[6] = (fullstring[6]^len(fullstring))/len(fullstring)
if len(fullstring) >= 7:
    fullstring[7] = (fullstring[7]^len(fullstring))/len(fullstring)
if len(fullstring) >= 8:
    fullstring[8] = (fullstring[8]^len(fullstring))/len(fullstring)
if len(fullstring) >= 9:
    print 'Error: string length overloaded cipher'
else:
    fullstring = fullstring[1:len(fullstring)]
    print fullstring

and getting error:

 File "python", line 30
if len(fullstring) >= 1:
                       ^
SyntaxError: invalid syntax

I'm not entirely sure whether it's a problem with line 29,(fullstring[0] = (fullstring[0] * pow(len(fullstring)) / len(fullstring)), or with line 30 itself. It used to run, but after I put in a word, it would crash, as one of my >='s were =>'s instead. However, this is no longer the case.

If anyone has any suggestions for how to make this better, I would greatly appreciate it, myself being a bit of a python novice.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire