just wondering if you could give me some pointers on how to make my code better? I've been looking through the forums and nobody did it like this.

def scrabble_score(word):
    total = []
    for x in word.lower():
    return sum(total)

It works but I don't know if it is actually the best way to do it and I was wondering for some pointers on best practice etc.

Split from Scrabble_score Minor Doubt

Scrabble_score Minor Doubt

i would choice terablaster94788 approach, your approach means i first have to construct a list into memory, before taking the sum, while terablaster his approach just does simple math operations

In such a small program, there won't be much difference between these two approaches, both are fine


So I'm guessing that in larger programs this would be an issue and would take up large amounts of memory?
Thank you for you help by the way.


Yes, you are right. Besides you take two steps:

creating list
doing math

where terablaster takes one step:

doing math

its a small difference. If your lists don't get very big, its no problem.


Thank you for your help! :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.