Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First - Second - Third - Last - what's the goal #14

Open
johnylemony opened this issue Sep 26, 2017 · 4 comments
Open

First - Second - Third - Last - what's the goal #14

johnylemony opened this issue Sep 26, 2017 · 4 comments

Comments

@johnylemony
Copy link

johnylemony commented Sep 26, 2017

Hello,
I am not sure what is the goal here, do we need to make few if statements to correlate strings with positions ? ex. if position = "first" insert(0) ?

It does work, but that does not seem to be efficient, am I missing something here ?

@johnylemony johnylemony changed the title What's the goal First - Second - Third - Last - what's the goal Sep 26, 2017
@sirpwn4g3
Copy link

Apparently so, which is not indicated. I don't mind combining what we've learned, I'd just like to know that we're combining elements, thus far I've been under the impression that we're learning bit by bit and will be combining later.

@Blastguy
Copy link

I kind of cheated by doing this:

def insert_human(a_list, position, elem):
if position is 'first':
position = 0
elif position is 'second':
position = 1
elif position is 'third':
position = 2
elif position is 'last':
position = 3
a_list.insert(position, elem)
return a_list

I don't know how to convert string words into integer value except by using the if command as I did above, but that's HEAVILY restricting it to just meet the requirements of the test.

@ajtran303
Copy link

Blastguy that's an interesting solution! Did anybody come up with something different?

@illya2412
Copy link

@Blastguy, the position should be replace with index.

if position == 'first':
index = 0
and so on...

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

No branches or pull requests

6 participants