DEV Community

Cover image for Name to Number Converter
Scott Gordon
Scott Gordon

Posted on

2 1

Name to Number Converter

# name_to_number_converter.py
#   This program calculates the numeric value of a single name based on
#   the provided input and the assigned letter values. a=1, b=2, c=3 ...
# by: Scott Gordon

# Print welcome message
print("***** Welcome to The Name to Number Converter *****")

# Get user input and assign it to the name variable and convert to lowercase
name = input("What is the name you would like to calculate? ")
name = name.lower()

# Create a lookup table of the alphabet.
alphabet = "abcdefghijklmnopqrstuvwxyz"

# Iterate through each letter in the name variable
sum = 0
for letter in name:
    # TODO Each pass add the index number from the lookup table to the variable sum.
    sum += (alphabet.index(letter)+1)

# Print the value of the name to the end user.
print(f"The value of the name you entered is {sum}.")
Enter fullscreen mode Exit fullscreen mode

Photo by Jon Tyson on Unsplash

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay