Sling Academy
Home/Python/Python: Converting a string to lowercase/uppercase

Python: Converting a string to lowercase/uppercase

Last updated: May 25, 2023

In Python, you can use the str.lower() and str.upper() methods to change the case of all characters in a string to lowercase or uppercase, respectively. These methods have been part of the programming language for almost two decades. They are still widely used today.

Converting to lowercase using the lower() method

Example:

my_string = "Welcome to Sling Academy!"
lowercase_string = my_string.lower()
print(lowercase_string)

Output:

welcome to sling academy!

Converting to uppercase using the upper() method

Example:

my_string = "Some greate RPG games are Witcher 3, Elden Ring, Cyberpunk 2077, and God of War."
uppercase_string = my_string.upper()
print(uppercase_string)

Output:

SOME GREATE RPG GAMES ARE WITCHER 3, ELDEN RING, CYBERPUNK 2077, AND GOD OF WAR.

Next Article: Python: 4 Ways to Convert a String into a List

Previous Article: Python: 8 Ways to Concatenate Strings

Series: Working with Strings in Python

Python

You May Also Like

  • Introduction to yfinance: Fetching Historical Stock Data in Python
  • Monitoring Volatility and Daily Averages Using cryptocompare
  • Advanced DOM Interactions: XPath and CSS Selectors in Playwright (Python)
  • Automating Strategy Updates and Version Control in freqtrade
  • Setting Up a freqtrade Dashboard for Real-Time Monitoring
  • Deploying freqtrade on a Cloud Server or Docker Environment
  • Optimizing Strategy Parameters with freqtrade’s Hyperopt
  • Risk Management: Setting Stop Loss, Trailing Stops, and ROI in freqtrade
  • Integrating freqtrade with TA-Lib and pandas-ta Indicators
  • Handling Multiple Pairs and Portfolios with freqtrade
  • Using freqtrade’s Backtesting and Hyperopt Modules
  • Developing Custom Trading Strategies for freqtrade
  • Debugging Common freqtrade Errors: Exchange Connectivity and More
  • Configuring freqtrade Bot Settings and Strategy Parameters
  • Installing freqtrade for Automated Crypto Trading in Python
  • Scaling cryptofeed for High-Frequency Trading Environments
  • Building a Real-Time Market Dashboard Using cryptofeed in Python
  • Customizing cryptofeed Callbacks for Advanced Market Insights
  • Integrating cryptofeed into Automated Trading Bots