Finding ideal sport based on weighted attributes The program takes weighted strengths of the human body (arms/legs/core/mind) based on the required attributes for a sport, then tells you the resulting sport. The program is obviously really ugly. Is there a way I could use dictionaries and a lambda function to find a max instead? This latter part is what I don't know how to do.

print("Welcome to What's your ideal sport! Answer the following questions on a scale from 1-10.")

leg_strength = int(input("How good is your leg strength / speed?"))
arm_strength = int(input("How good is your arm strength?"))
core_strength = int(input("How strong are your abs?"))
mental_strength = int(input("How intelligent are you?"))
reaction_time = int(input("How fast are your reactions?"))

# Sports are: Soccer, Football, Tennis, Swimming, Basketball, Track, Gymnastics, and Chess.

sports = []

soccer = (arm_strength*5) + (reaction_time*2) + (mental_strength) + (arm_strength) + (core_strength)
sports.append(soccer)
chess = mental_strength * 10
sports.append(chess)
football = (arm_strength*4) + (core_strength*3) + (leg_strength*3)
sports.append(football)
tennis = (reaction_time*3) + (arm_strength*4) + (core_strength*2) + (mental_strength)
sports.append(tennis)
swimming = reaction_time + (core_strength*3) + (arm_strength*3) + (leg_strength*3)
sports.append(swimming)
basketball = (leg_strength*2) + (arm_strength*5) + (mental_strength*2) + core_strength
sports.append(basketball)
track = (leg_strength*6) + (arm_strength*2) + (reaction_time) + (mental_strength)
sports.append(track)
gymnastics = (leg_strength*3) + (arm_strength*3) + (core_strength*3) + mental_strength
sports.append(gymnastics)

print(sports)

best = max(sports)
sports.index(best)

indices = []

for sport in sports:
    if sport == best:
        indices.append(sports.index(sport))

result = []

for index in indices:
    if index == 0:
        result.append("Soccer")
    elif index == 1:
        result.append("Chess")
    elif index == 2:
        result.append("Football")
    elif index == 3:
        result.append("Tennis")
    elif index == 4:
        result.append("Swimming")
    elif index == 5:
        result.append("Basketball")
    elif index == 6:
        result.append("Track")
    elif index == 7:
        result.append("Gymnastics")

    print("Your best olympic sport(s) are: {0}.".format(result))
Perhaps you could represent the weightings of each trait as a tuple of multipliers, which are applied to the input values.

Here you have a list of weightings, to which it's trivial to add entries.

from operator import itemgetter, mul
from itertools import groupby, starmap

print("Welcome to What's your ideal sport! "
      "Answer the following questions on a scale from 1-10.")

traits = ('leg', 'arm', 'core', 'mental', 'reaction')

questions = ["How good is your leg strength / speed? ",
             "How good is your arm strength? ",
             "How strong are your abs? ",
             "How intelligent are you? ",
             "How fast are your reactions? "]

responses = [int(input(q)) for q in questions]

print("weights: ")
for t, a in zip(traits, responses):
    print("%s strength = %d" % (t, a))

weightings = [
    # sport, (legs, arms, core, mental, reactions)
    ('soccer',     (5, 2, 1, 1, 1)),
    ('chess',      (1, 1, 1, 10, 1)),
    ('football',   (3, 4, 3, 1, 1)),
    ('tennis',     (1, 4, 2, 1, 3)),
    ('swimming',   (3, 3, 3, 1, 1)),
    ('basketball', (2, 5, 1, 2, 1)),
    ('track',      (6, 2, 1, 1, 1)),
    ('gymnastics', (3, 3, 3, 1, 1))
]


def calcscore(weights, answers):
    ''' calculate the score for a given set of weights and answers, by
        multiplying each answer by the matching weight and adding them
        all together.
    '''
    return sum(weight * answer for (weight, answer) in zip(weights, answers))
    # more esoteric implementation.
    #return sum(starmap(mul, zip(weights, answers)))

# results prior to sorting
result = [(name, calcscore(traits, responses)) for (name, traits) in weightings]

# sorted results prior ordered by score descending
sresult = sorted(result, key=itemgetter(1), reverse=True)

# group and take first group. It should never be empty.
grouper, group = next(groupby(sresult, key=itemgetter(1)))

print('results:')
print("with score %d" % grouper)
print("we have the sports")
for name, score in group:
    print('%s - %d' % (name, score))


Some of the values in the weightings should probably be zero rather than one. To represent an absence of this trait from the calculation. It will be straightforward for the op to modify these themselves. I am demonstrating the concept.