ItSolutionStuff.com

How to Get First Character from String in Python?

By Hardik Savani October 30, 2023
Python

Hey Folks,

Now, let's see an article of python get first character from string. In this article, we will implement a python get first character in string. It's a simple example of how to get first character in string python. We will look at an example of how to get first character from string in python. Here, Create a basic example of how to get first character in python.

In this example, i will add myString variable with hello string. Then we will use key to getting first character from string in python. So, without further ado, let's see simple examples: You can use these examples with python3 (Python 3) version.

Example:

main.py

# Declare String Variable
myString = "Hello, This is ItSolutionStuff.com"
  
# Getting First Character from String
firstChar = myString[0]
  
print(firstChar)

Output:

H

I hope it can help you...

Tags: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube