This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
The following code works but I don't understand why? I would think [:2] would give me the first three letters but in fact gives me two. I have included the instructions for reference.
Write a function that stutters a word as if someone is struggling to read it. The first two letters are repeated twice with an ellipsis ... and space after each, and then the word is pronounced with a question mark ?.
word = input("Enter a word.")
def stutter(word):
sword = word
print (sword[:2],"...",sword[:2],"...",sword,"?")
stutter(word)
Here is the output.
Enter a word.Function
Fu ... Fu ... Function ?
Assuming the index starts at zero shouldn't [:1] give me the first two letters?
Thanks
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnpython...