Posts

Showing posts from November, 2016

Some Sample Git Commands for beginners

If using bit bucket, it takes certain steps for granted and as such can give you lot of pain. But here is how I fixed this issue. In your root directory of your project git init git add . git commit -m "message" Then follow the steps from the initial page of the repo git remote add origin https://xxxx@bitbucket.org/xxx/xxx.git git push -u origin --all git push -u origin --tags Hope I've helped someone!

append multiple values for one key in Python dictionary

years as keys and an array for each year containing a list of values associated with that year, right? Here's how I'd do it: years_dict = dict () for line in list : if line [ 0 ] in years_dict : # append the new number to the existing array at this slot years_dict [ line [ 0 ]]. append ( line [ 1 ]) else : # create a new array in this slot years_dict [ line [ 0 ]] = [ line [ 1 ]]   What you should end up with in years_dict is a dictionary that looks like the following: { "2010" : [ 2 ], "2009" : [ 4 , 7 ], "1989" : [ 8 ] }   In general, it's poor programming practice to create "parallel arrays", where items are implicitly associated with each other by having the same index rather than being proper children of a container that encompasses them both.