samedi 28 octobre 2017

why is the 'else' a syntax error in my pyton code?

I can't find the reason why the 'else' at the end of my code is considered a syntax error. Any ideas?

balagan = "9abbcd" 
first_char_dig = balagan[0].isdigit(0)
if first_char_dig:
    if first_char_dig < 9:
        a0_new = int(balagan[0]) + 1
    else:
        a0_new = 0
else:
    a0_new = balagan[0]
a1_new = balagan[-2]
amin2_new = balagan[1]
mid_balagan_len = len(balagan) / 2
mid_balagan = balagan[mid_balagan_len]
if mid_balagan.isdigit():
    mid_new = mid_balagan
else:
    if mid_balagan.isupper():
        mid_new = lower(mid_balagan)
    else:
        mid_new = upper(mid_balagan)
if balagan[mid_balagan_len] != balagan[-2]:
    new_str = str(a0_new)+ str(a1_new) + balagan[2:mid_balagan_len] + str(mid_new) + [balagan[mid_balagan_len+1:-2] + str(amin2_new) + balagan[-1]
**else: #why is this a syntex error?**
    new_str = str(a0_new) + str(a1_new)+ balagan[2:mid_balagan_len] + str(mid_new) + str(amin2_new) + balagan[-1]
print new_str

Aucun commentaire:

Enregistrer un commentaire