Reputation: 35
For example, if I entered "Harry Potter"
into the following code. What should I write in the blank spaces so that First_letter
will be assigned with H
, Second_letter
with a
, etc.
If possible, please also explain how the code works.
Any help will be greatly appreciated!
Name = input("Enter your name")
First_letter = ____
Second_letter = ____
Third_letter = ____
Upvotes: -3
Views: 13987
Reputation: 31672
You could use index for str
objects:
Name = input("Enter your name")
First_letter = Name[0]
Second_letter = Name[1]
Third_letter = Name[2]
Upvotes: 1