Python Forum
How to apply function lower() to the list?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to apply function lower() to the list?
#1
Hi, everyone!
I have a list with the names of users:
users = ['Timoteusz', 'MAD', 'GaMer', 'ToXIC',....]
All the names are in different letter case.
How to apply function lower() to the copy of this list to make all the names lowercase? Huh
Reply
#2
users = ['Timoteusz', 'MAD', 'GaMer', 'ToXIC']

# using list comprehension
users_lower = [item.lower() for item in users]

# using map
users_lower2 = list(map(str.lower, users))
print(users_lower)
print(users_lower2)
Toltimtixma likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thanks! Thumbs Up Super! It works!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner Higher Lower Game wallytan 2 1,607 Sep-29-2022, 05:14 PM
Last Post: deanhystad
  IF statement to apply at each date illmattic 2 2,682 Apr-08-2021, 12:31 PM
Last Post: illmattic
  Function won't apply dynamically in timeseries illmattic 1 1,752 Jan-08-2021, 03:15 PM
Last Post: stullis
  lower() applied at in operator Beerforfree 3 2,339 Mar-22-2020, 11:51 AM
Last Post: ndc85430
  How to apply VLookup formula jonzee 2 3,568 Jan-12-2020, 04:16 PM
Last Post: Clunk_Head
  Issue in .apply function fullstop 0 1,511 Dec-17-2019, 01:29 PM
Last Post: fullstop
  How to change a dataframe column to lower case zhujp98 5 6,348 Oct-29-2019, 06:42 PM
Last Post: zhujp98
  I created a function that generate a list but the list is empty in a new .py file mrhopeedu 2 2,324 Oct-12-2019, 08:02 PM
Last Post: mrhopeedu
  Converting Smiles to Fingerprint with pandas iterrows/apply-function: Jompie96 0 2,504 Jul-04-2019, 01:50 PM
Last Post: Jompie96
  Apply a function with pandas Jompie96 2 2,235 Jun-13-2019, 07:04 PM
Last Post: Jompie96

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020