Skip to content

Jerry Samuels Jr.#34

Open
DiwthL83 wants to merge 1 commit intoomahacodeschool:masterfrom
DiwthL83:master
Open

Jerry Samuels Jr.#34
DiwthL83 wants to merge 1 commit intoomahacodeschool:masterfrom
DiwthL83:master

Conversation

@DiwthL83
Copy link

Submitting my strings portion of the 5/29/16 assignment

Replace me with your response...
Steps to retrieve the 6th character in "Ada Lovelace":
1) string1 = "Ada Lovelace"
2) string1[5..5]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command string_name[x..n] is typically used to return a range/selection. How might you simplify the command, since we are just returning one character?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could jut use the literal itself to grab the 6th character:

"Ada Lovelace"[5..5]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! You definitely could. I don't mind your variable use, actually. I'm more concerned about the values within the brackets.

With that in mind, how might you simplify string1[5..5]?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could just type in the one position I'm looking for to return its value, like so:

string1[5]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments