Skip to content

flavia bastos

  • Home
  • About

Tag: code

Map a string in Python with enumerate

November 30, 2018November 30, 20181 Comment

Problem: create a map of the letters and indices in a string. My first approach was to loop over the string using range(len(s)), and checking if the letter exists in the map before adding it: s = 'mozzarella' mapped_s = {} for i in range(len(s)): if s[i] in mapped_s: mapped_s[s[i]].append(i) else: mapped_s[s[i]] = [i] print(f' mapped: … Continue reading Map a string in Python with enumerate

Find me

  • Twitter
  • GitHub
  • LinkedIn

Recent Posts

  • Developing inside a Docker container
  • How to permit nested parameters in Rails
  • 5 razões pra começar a aprender JavaScript
  • Git, GitHub and GitLab. Are they all the same thing?
  • Find the commit that introduced a bug in your code: how to use git bisect in 7 steps

Categories

  • books (2)
  • career (1)
  • command line (12)
  • go (1)
  • gRPC (2)
  • housekeeping (2)
  • how-to (5)
  • JavaScript (4)
  • networking (3)
  • python (8)
  • quick-tip (6)
  • rails (1)
  • til (7)

Tags

about argv aws beginner book built-in code coding milestone command line data structure debug debugger dev environment dictionary docker git go golang gRPC gRPC-Web how-to ifconfig iniciante JavaScript js lambda lessons linux list nc netcat network pdb ping productivity profiling prompt pt-BR python quick-tip rails set sort ss til tools traceroute tuple vi vim

Follow via RSS

  • RSS - Posts

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 134 other followers

A WordPress.com Website.