I am job-searching, and running into some coding challenges. Most of them are simple - some seem to want one-line solutions that require two cups of coffee and a half-hour to figure out what they want. Others are far above where my skills lie, and these I give a try for, and learn.
And then there are the ones that offer, seemingly randomly, a challenge - within my skills (or at least my research skills) - that could be used as part of a larger project that I want to work on. This was the case last week, when I tried for a position that was a bit above what I felt I could do comfortably.
The challenge was to let someone enter items, and then give back their location. In a language I am just familiar enough to be a danger to myself in. Happily, and thinking forward about how I could use this as a part of a larger program that would use something like this to interact with the user. And also, this is command line, and thinking of how to set this up to use a more-graphical interface.
Which means, as you may have guessed, that the program was not done in time to let me be considered for the job. It *still* isn't totally done - I just now solved a section that had me confounded.
This was taking two separate inputs - the item, and then its location (still working out how to insure that multiple items stored in the same location can be found), and adding them to a Python dictionary. Which has its own restrictions, but it's a good learning tool. If I figure this out, and need to change types later, I'll still have learned some valuable things.
Like how to get these inputs, typed separately, into the key:value pairs that are needed to add them to a dictionary.
Of course, the first thing I did was to set up limits on the input fields - so far, they are unique item name between 1 and 50 characters, and the same restrictions for the location (no naming everything "Shoes" and putting them in "closet"!), and adding a word to type in to stop the entry. So far, this worked - I was delighted! And without wanting to toss the computer through the nearest wall.
Of course, the first thing I did was to set up limits on the input fields - so far, they are unique item name between 1 and 50 characters, and the same restrictions for the location (no naming everything "Shoes" and putting them in "closet"!), and adding a word to type in to stop the entry. So far, this worked - I was delighted! And without wanting to toss the computer through the nearest wall.
But, the next day, these guards got removed - I wanted to get the item name and location into a dictionary, and print out the items already listed. If I placed things in the dictionary, they would show nicely. So that part worked.
But, adding things to the dictionary was not going well - it needs the information in a form that it could accept. And the easiest thing was a dictionary. But making a dictionary to fill a dictionary? Why can't I just toss these two into the update, and be done with it?
After multiple error messages (I'm expecting 2 items you have given me 4, or 1) I finally resorted to looking at StackOverflow. This is something I try NOT to do - I prefer documentation and a bit of freedom to play. But there, on the first page of search results, was a simple one-line command to get the inputs separated, and then get them into pairs.
All right, I don't like it, but I can have the item and its location typed in at one time. Which is why the guards went away. And that didn't work. I missed something. So back to staring at the screen - which only makes me less likely to see the error.
All right, I don't like it, but I can have the item and its location typed in at one time. Which is why the guards went away. And that didn't work. I missed something. So back to staring at the screen - which only makes me less likely to see the error.
It's a nice day - and someone else wants to go for a walk. This should help me figure this out, or at least stop me from trying the same thing multiple times, and getting upset because it doesn't work. And the breeze felt good - the sunshine even better, and feeling like it was too warm outside was a change.
Type the formula in - since it's simple, I don't need to copy it - and try. And, it doesn't work. It's getting late, and I have to cook tonight, so back over to the SO page, and copy the line.
And feel very silly - the syntax is {[ ]} (or square braces inside curly braces). And I'd forgotten the inner square braces. Try this, add some silly data, and it worked! I was able to see both the updated dictionary, and get back the item that I'd added to the dictionary.
So this worked - and now I can move on to the next part of the issue. These lessons are going to be valuable as I make larger projects.
I hope you think of sharing what you learn, so the rest of us can learn from your errors and successes!