223k views
5 votes
Python String Functions: Create a new Python Program called StringPractice. Prompt the user to input their name, then complete the following:

Length
• Print: “The length of your name is: [insert length here]”
Equals
• Test to see if the user typed in your name. If so, print an appropriate message

Really appreciate the help.

1 Answer

3 votes

#Swap this value by your name. Mine is Hamza :)

my_name = "Hamza"

#Get input from user.

inp = input("What's your name?: ")

#Print the length of his/her name.

print("The length of your name is",len(inp),"characters.")

#Check if the input matches with my name?

#Using lower() method due to the case insensitive. Much important!!

if(inp.lower()==my_name.lower()):

print("My name is",my_name,"too! Nice to meet you then.")

User Martin Bories
by
8.0k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.