Featured Post

How to Build CI/CD Pipeline: GitHub to AWS

Image
 Creating a CI/CD pipeline to deploy a project from GitHub to AWS can be done using various AWS services like AWS CodePipeline, AWS CodeBuild, and optionally AWS CodeDeploy or Amazon ECS for application deployment. Below is a high-level guide on how to set up a basic GitHub to AWS pipeline: Prerequisites AWS Account : Ensure access to the AWS account with the necessary permissions. GitHub Repository : Have your application code hosted on GitHub. IAM Roles : Create necessary IAM roles with permissions to interact with AWS services (e.g., CodePipeline, CodeBuild, S3, ECS, etc.). AWS CLI : Install and configure the AWS CLI for easier management of services. Step 1: Create an S3 Bucket for Artifacts AWS CodePipeline requires an S3 bucket to store artifacts (builds, deployments, etc.). Go to the S3 service in the AWS Management Console. Create a new bucket, ensuring it has a unique name. Note the bucket name for later use. Step 2: Set Up AWS CodeBuild CodeBuild will handle the build proces

Python Split String: Techniques and Best Practices

Here is an example for splitting a string in Python. The functions you need are strip and split to split string, or text. 

python split string


Here's the string taken for split

My task is I want to split address string. Historically, the address is lengthy. It contains the door number, floor number, street number, and street name.

Rama Krishna 20/3 ABC street EFG Nagar US 234567

How to Split a string

The python split string works in two steps. The first step is to use strip function, which removes both leading and trailing spaces. Next, use the the split function, which splits the input string, or text into a list.

Python program

user_address = input("Enter an address")

if user_address.strip(): #check that string is not empty (after removing leading
#and trailing spaces)
    print("Your address is " + user_address)
split_address = user_address.split()
print(split_address)

Output

Interactively, it asks the user to enter the address. After the code runs, the address splits into separate strings in a list.

Enter an address
Rama Krishna 20/3 ABC street EFG Nagar US 234567

Your address is Rama Krishna 20/3 ABC street EFG Nagar US 234567
['Rama', 'Krishna', '20/3', 'ABC', 'street', 'EFG', 'Nagar', 'US', '234567']

** Process exited - Return Code: 0 **
Press Enter to exit terminal

Comments

Popular posts from this blog

How to Fix datetime Import Error in Python Quickly

How to Check Kafka Available Brokers

SQL Query: 3 Methods for Calculating Cumulative SUM