• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Script Everything

  • Spreadsheets
  • Python
  • Blog

one-liners

Best 2 Ways To Create A Python List With Identical Elements: One-Liners

June 11, 2023 by Ryan Sheehy

How can you create a list with identical elements in it with Python? There are two ways to create a list with identical elements in Python. One method is fairly straightforward and easy to remember, whereas the other involves the itertools … [Read more...] about Best 2 Ways To Create A Python List With Identical Elements: One-Liners

Filed Under: lists Tagged With: one-liners

How To Read File Into List With 1 Line Of Code In Python

March 28, 2022 by Ryan Sheehy

How do read the contents of a file in Python and insert these lines into a list? Using the built-in function open() and the asterisk operator * a file's contents can easily be translated into a list with the following one-liner: … [Read more...] about How To Read File Into List With 1 Line Of Code In Python

Filed Under: lists , Python Tagged With: one-liners

Change List Elements To Int In Python: 1 Line Of Code

March 25, 2022 by Ryan Sheehy

How do you convert a list of strings to a list of integers in Python? And can you do it with one line of code? To convert a list of strings to a list of integers use the built-in map() function if you know the contents of the original list will … [Read more...] about Change List Elements To Int In Python: 1 Line Of Code

Filed Under: lists , number , strings Tagged With: one-liners

How To Remove File Extension From Path String In Python: One-Liner

March 24, 2022 by Ryan Sheehy

How do you remove the file extension from a path in Python? And can you do it using just one line of code? The file extension is generally the last set of characters after the final period in a path string. Removing the file extension helps with … [Read more...] about How To Remove File Extension From Path String In Python: One-Liner

Filed Under: strings Tagged With: one-liners

How To Capitalize First Letter Of Every Word In Python (One-Liner)

February 2, 2022 by Ryan Sheehy

How do you capitalize the first letter of each word in a string using Python? To capitalize the first letter of every word in Python using one line of code enter the following: " ".join([x.capitalize() for x in my_string.split()]). Here is an … [Read more...] about How To Capitalize First Letter Of Every Word In Python (One-Liner)

Filed Under: Python Tagged With: one-liners

How To Split A String In Half In Python: 1 Line Of Code

January 21, 2022 by Ryan Sheehy

How do you split a string into two equal halves using Python? To tackle this exercise you need to know how you’re going to operate on odd numbered string lengths. For example, how would you like your code to operate on the string halve. As it has … [Read more...] about How To Split A String In Half In Python: 1 Line Of Code

Filed Under: Python , strings Tagged With: one-liners

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to Next Page »

Primary Sidebar

Hello! My name is Ryan Sheehy the author of ScriptEverything.com

This website acts as a second brain of sorts for all the hacks and explorations I find when trying to solve problems at work.

About Me

Footer

Spreadsheets

I have been using spreadsheets since as early as 1996 and I continue to use this great productivity tool on a daily basis.

Check out some of my most recent discoveries about spreadsheets.

Python Code

I have been using Python since the late 1990’s due to the limitations of Excel’s VBA. I enjoy being able to wrangle and fetch data externally using Python.

Discover more of what I’ve found with Python.

Apps

Sometimes I play, hack and tinker with other applications to scratch an itch.

To find out the latest hack check out my blog feed.

Copyright © 2023 ScriptEverything.com

  • Contact
  • Privacy Policy