My own code

How do you capatalize all first letters but for all of the if statements

[/codebyte]
name = input("What is your name? ")

if (name == “esha”):

print(“Hello Esha I have been expecting you”)

name = name.lower()

elif (name == “rachel”):

print (“Hi Rachel! The pizza was cold at the formal”)

name = name.lower()

else:

print(“Hello " + name +”!")

name = name.lower()

1 Like

What do you mean:

And make sure you format code correctly: [Learn more] Welcome to the Codecademy Community Forums!

print('Hello' + name[0].upper() + name[1:])

  • name[0] tells it to give the first character in name
  • name[1:] gives you the slice of name from 1 to the end since no number is given after the semi colon it defaults to return all the way to the end of the string.
  • all arrays start counting with 0 so its the first and 1 is the second and so on

you could also save it to a variable before printing

name = 'rachel'
capitalized_name = name[0].upper() + name[1:]
print( capitalized_name )

How is name[0] capitalized?

lol thanks I need to make sure my explanation matches both or all parts. I made the edit and corrected it.

1 Like