mercredi 8 mai 2019

How to add the value in string and go to next letter in python

Two people participate in competition . There will be one easy, difficult and medium question

Difficulty Score E 1 M 3 H 5

User will enter two strings e and b , and function should find out greater scores or tie.

my code is


def winner(e, b):
    sume = 0
    sumb =0
    highest = 0
    x = False
    for i in (range(len(erica))):
        if (erica[i] =='E'):
            sume +=1
            x = True
        elif (erica[i] =='M'):
            sume = sume+3
            x = True
        elif (erica[i] =='H'):
            sume +=5
            x = True
        return sume
if __name__ == '__main__':
    erica = input()
    bob = str(input())
print(winner(e,b))

When I enter HEM for e it should give 9 but it only gives 5

Aucun commentaire:

Enregistrer un commentaire