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

  • GitHub
  • LinkedIn
  • Twitter

Recent Posts

  • Git Squash Tutorial: How to Combine Git Commits for a Clear and Organized Commit History
  • TIL: time travel with Python’s standard library
  • Django Rest Framework: adding DateTimeField format serializer validation
  • Book review: The Programmer’s Brain
  • Como reverter um commit no git

Categories

  • books (3)
  • career (1)
  • command line (14)
  • git (9)
  • go (1)
  • gRPC (2)
  • housekeeping (2)
  • how-to (9)
  • JavaScript (4)
  • networking (3)
  • python (12)
  • quick-tip (6)
  • rails (1)
  • til (10)
  • web development (3)

Tags

about argv aws beginner book built-in career code coding milestone command line data structure debug debugger decorator dev environment dictionary django docker drf 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 tutorial vi vim

Follow via RSS

  • RSS - Posts
A WordPress.com Website.
  • Follow Following
    • flavia bastos
    • Already have a WordPress.com account? Log in now.
    • flavia bastos
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar