Assigning variable to letter


#1

"On line 13, assign the variable fifth_letter equal to the fifth letter of the string “MONTY”.

Remember that the fifth letter is not at index 5. Start counting your indices from zero."

MONTY, string contains 5 letters, what will the 5th letter be if we start counting from 0, and why ?
Thx

Strings and Console Output


#2

M is the first letter, I’m sure you can count from there


#3

NO! M is zeroth letter …


#4

I misunderstood the istruction, my bad


#5

also, how to delete post? thx


#6

First, fifth, second, third, fourth, fifth talk about how many there are after having included each item, that’s a different thing from locations

Depending on whether or not one considers 0 the first natural number, one might consider this a bug in the english language, at the same time, I’m not sure what I would suggest instead, if anything


#7

I think it makes some sense to consider zeroth the count at which none have been included, rather than to consider zeroth the first item, so perhaps English has it right after all.

…I expect that even if asking a mathematician, one would choose the answer when choosing which one to ask


#8

What a coincidence, i’m a mathematician… kind of. English has is right for sure : p


#9

Lesson 1/16 & 3/16 (Escaping characters) -

quote:

“Strings need to be within quotes.” (1/16)

"This code breaks because Python thinks the apostrophe in ‘There’s’ ends the string. " (3/16)

caesar = ‘Graham’ equivalent to caesar = "Graham"
praline = ‘John’ " praline = "John"
viking = ‘Teresa’ " viking = “Teresa”

It seems I can use quotes and/or apostrophes interchangeably ? Both compiled OK on your “interpreter” without error message

Please advise

thank you

Alan.


#10

https://www.quora.com/Is-there-a-difference-between-and-when-coding-in-python
this will help you


#11

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.