Create an account


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 20,125
» Latest member: udwivedi923
» Forum threads: 21,822
» Forum posts: 22,691

Full Statistics

Online Users
There are currently 901 online users.
» 0 Member(s) | 896 Guest(s)
Applebot, Baidu, Bing, Google, Yandex

 
  [Tut] Python | Split String After Delimiter
Posted by: xSicKxBot - 11-30-2022, 12:30 AM - Forum: Python - No Replies

Python | Split String After Delimiter

Rate this post

Summary: You can use one of the following methods to split a string after the delimiter –

  • Using split
  • Using string slicing
  • Using regex
  • Using partition
  • Using removeprefix

Minimal Example


# Given String
chat = "Python Founder: Guido van Rossum"
# Method 1
print(chat.split(':')[1])
# Method 2
print(chat[chat.index(":")+1:])
# Method 3
import re
print(re.findall(":(.*)", chat)[0])
# Method 4
print(chat.partition(':')[2])
# Method 5
print(chat.removeprefix('Python Founder:'))

Problem Formulation


 ?Problem: Given a string; How will you split the string after the delimiter? The output must only contain the substring after the delimiter.

Example


Let’s visualize the problem with the help of an example:

# Input
text = "Subscribe to - Finxter"
# Expected Output
Finxter

⭐Method 1: Using split()


Approach: First, we will simply split thestring using “-” as the delimiter. Next, to extract the string before the delimiter we will use the index of the required substring. As the split() function returns a list of substrings, we can extract the last part using list indexing [1] (Indexing starts at 0).

Code:

text = "Subscribe to - Finxter"
res = text.split('-')[1]
print(res)
# Finxter

Note: The split() function splits the string at a given separator and returns a split list of substrings. It returns a list of the words in the string, using sep as the delimiter string.

?Related Read: Python String split()

⭐Method 2: Using String Slicing


Prerequisite: String slicing is a concept of carving out a substring from a given string. Use slicing notation s[start:stop:step] to access every step-th element starting from index start (included) and ending in index stop (excluded). All three arguments are optional, so you can skip them to use the default values.

Approach: First, we will use the index() method to find the occurrence of the delimiter in the text. Next, we will slice the string from the index next to the index of the delimiter until the end of the string. Note that we are starting from the index of the delimiter+1 because we don’t want to include it in the final output.

Code:

text = "Subscribe to - Finxter"
res = text[text.index("-")+1:]
print(res) # Finxter

Note:

The index()  method is used to return the index of the first occurrence of the specified substring, like find() but it raises a ValueError if the substring is not found.

?Related Reads:
String Slicing in Python

Python String index()

⭐Method 3: Using regex


The re.match(pattern, string) method returns a match object if the pattern matches at the beginning of the string. The match object contains useful information such as the matching groups and the matching positions.

Approach: Use the expression re.findall("-(.*)", given_string) to match and store all characters that come after the “-“.

Code:

import re text = "Subscribe to - Finxter"
print(re.findall("-(.*)", text)[0]) # Finxter

?Related Read: Python Regex Match

⭐Method 4: Using partition


The partition() method searches for a separator substring and returns a tuple with three strings: (1) everything before the separator, (2) the separator itself, and (3) everything after it. It then returns a tuple with the same three strings.

Approach: We have used the partition method and used “-” as a separator. As we only need the substring before the delimiter, we have used the index of the required substring on the returned tuple and just printed the third element of the tuple (everything before the separator).

Code:

text = "Subscribe to - Finxter"
res = text.partition('-')[2]
print(res) # Finxter

?Related Read: Python String partition()

⭐Method 5: Using removeprefix


If you are using Python 3.9 or above then Python facilitates you with the removeprefix method that allows you to remove the substring that comes before a specified substring. Here’s a quick look at how the removeprefix method works –

source: https://docs.python.org/3.9/library/stdtypes.html#str.removeprefix

Code:

text = "Subscribe to - Finxter"
print(text.removeprefix('Subscribe to -')) # Finxter

Conclusion


Hurrah! We have successfully solved the given problem using as many as five different ways. I hope you enjoyed this article and it helps you in your Python coding journey. Please subscribe and stay tuned for more interesting articles!


Do you want to master the regex superpower? Check out my new book The Smartest Way to Learn Regular Expressions in Python with the innovative 3-step approach for active learning: (1) study a book chapter, (2) solve a code puzzle, and (3) watch an educational chapter video.



https://www.sickgaming.net/blog/2022/11/...delimiter/

Print this item

  (Indie Deal) Monster Spark Bundle & Black Friday are officially here
Posted by: xSicKxBot - 11-30-2022, 12:29 AM - Forum: Deals or Specials - No Replies

Monster Spark Bundle & Black Friday are officially here

Monster Spark Bundle | 6 Steam Games | 95% OFF
[www.indiegala.com]
All you need is that one spark to unleash the monster in you, one that will enjoy a video game experience like never before: DwarfHeim, RIOT: Civil Unrest, The Long Reach, Sparklite, Mainlining Deluxe Edition, Monster Harvest.

Black Friday is here...officially!
[www.indiegala.com]
Extra 10% cashback as a BONUS in this period only!
https://www.youtube.com/watch?v=5B3fuoNaoj4
Tales of Giveaways
[www.indiegala.com]


https://steamcommunity.com/groups/indieg...9740505321

Print this item

  PC - Dying Light 2 Stay Human: Bloody Ties
Posted by: xSicKxBot - 11-30-2022, 12:29 AM - Forum: New Game Releases - No Replies

Dying Light 2 Stay Human: Bloody Ties



The Nightrunners were a sign of better things to come. Unfortunately, all good things eventually come to an end, but for you, this is only the beginning.

Get ready for the release of Chapter 1: In the Footsteps of a Nightrunner, the biggest free content update since the release. Get ready to meet Harper, a Nightrunner of old. Help him in his efforts to combat the Special Infected that are endangering the people of Villedor.

Publisher: Techland

Release Date: Nov 10, 2022




https://www.metacritic.com/game/pc/dying...loody-ties

Print this item

  News - Apex Legends Mobile, Inscryption Highlight 2022 Apple App Store Awards
Posted by: xSicKxBot - 11-30-2022, 12:29 AM - Forum: Lounge - No Replies

Apex Legends Mobile, Inscryption Highlight 2022 Apple App Store Awards

Apple has revealed the recipients of the 2022 App Store Awards, with 16 games and apps named across iPhone, iPad, Mac, and more.

Apex Legends Mobile--the portable version of Respawn Entertainment's tactical team-based battle royale--was named the best game for iPhone in 2022, while puzzler Moncage received top honors for iPad. El Hijo, which follows a six-year-old boy trying to rescue his mother from bandits, was named the top game for Apple TV.

Apex Legends Mobile takes home Best iPhone Game of 2022.
Apex Legends Mobile takes home Best iPhone Game of 2022.

The list of games and apps recognized by the 2022 App Store Awards is as follows:

Continue Reading at GameSpot

https://www.gamespot.com/articles/apex-l...01-10abi2f

Print this item

  [Oracle Blog] Java and the New Duke Personality
Posted by: xSicKxBot - 11-29-2022, 05:54 AM - Forum: Java Language, JVM, and the JRE - No Replies

Java and the New Duke Personality

For 24+ years, Java technology has advanced the world we interact with every day. With Oracle’s stewardship, Java technology continues to offer developers innovative functionality to build out the next generation of applications that bring utility to us, both personally and professionally. And durin...


https://blogs.oracle.com/java/post/java-...ersonality

Print this item

  [Tut] 3 Easy Habits That Can Make You Rich as a Freelance Coder
Posted by: xSicKxBot - 11-29-2022, 05:54 AM - Forum: Python - No Replies

3 Easy Habits That Can Make You Rich as a Freelance Coder

5/5 – (1 vote)

In this article, I’ll show you three simple habits to get way more done, have a much easier and stress-free life, and make more money. Almost guaranteed. Based on science!

But there’s a catch: these habits are often tough to implement for employees. I know because I have been there and done that.

When I finally created my own freelance-based business as a coder, all people in my environment were employees, and, unfortunately, nobody I knew implemented them. So I almost missed them! ?

~~~

Here are the three daily habits that will increase the quality of your life and your success as a coder:

Habit #1 – Work from home



People think commute time is not a big deal.

In truth, commute time ranks among the most expensive things you can do and is highly detrimental to your financial success and your happiness.

Let’s start with happiness:

In a 2019 paper titled “How commuting affects subjective wellbeing”, researchers showed that long commute times reduce your happiness and can lead to mental issues like depression:

? “It is found that longer commute times are associated with lower job and leisure time satisfaction, increased strain and poorer mental health.”

I could provide many more sources showing similar results, but let’s move on to the financial and time impact.

The average one-way commute time for Americans is 27.6 minutes, according to the Census Bureau.


In a year with 260 working days, that’s a whopping 240 hours of reduced productivity that is stressful and reduces your work energy.

For employees, you could argue it doesn’t matter. But as a self-employed freelancer, you could work 240 hours with an average freelance developer income of $50 that’s a $12,000 annual time opportunity cost.

Over a working life of only 30 years, contributing $6,000 to a passive index fund (ETF) at an average 10% annual yield would result in a whopping $1,136,118 nest egg.


You may miss out on becoming a millionaire just because of one hour per day in commute time!

Okay, let’s assume you’re stuck in the conventional mindset of believing your time is “free” and it doesn’t matter.

? Question: How much does the commute time actually cost in hard dollars without considering opportunity time costs and the drain of energy and happiness?

The average American commutes 41 miles a day to and from work (US Censor Bureau).

The average cost per mile of driving a car is $0.58, according to the US Department of Energy.

So, the direct annual costs of commute time are 41 miles per day times $0.58 times 260 working days equals $6,182.

Thus, over 30 working years, here’s another missed $1.1 million USD nest egg if you’re the average American employee!


(See previous calculations.)

? Summary Commute: As an online freelance developer working from home, you’d easily pick up that $3.3 million USD over 30 years — just from saving commute time and investing the difference in the stock market.

And you’d be happier too!

I’d be missing out if I wouldn’t let you know about our current offer:

*** Become a Freelance Developer Course ***

But are there more simple gains you could add on top of those?

Yes, they exist! Let’s look at the second easy productivity habit that’s easy for freelancers but often tough to implement for employees!

Habit #3 – Have a 30-Minute Nap at Noon.



I sleep for half an hour every day at noon. My wife is from Spain, and it’s normal for my wife’s Spanish family to take a long siesta at noon.

Instead of plowing through a long 8-hour day until exhaustion, they work a couple of hours in the morning, sleep and recharge, and work for a couple of hours in the evening.


I love it – my quality of life has skyrocketed since I implemented this habit into my daily life.

And I became much more productive too.

Now you may ask: Is there scientific evidence on the benefits of daily afternoon naps?

You bet there is! In fact, there are too many studies to count. Here’s one:

In a popular MIT paper titled “The Economic Consequences of Increasing Sleep Among the Urban Poor,” researchers found that after more than three weeks of daily 30-minute naps, employees were more productive and invested more of their money into savings accounts.

Another paper titled “Effects of a Short Daytime Nap on the Cognitive Performance” demonstrated that napping in the afternoon improved all types of cognitive performance.

One study showed that the performance was improved by at least 2%, even considering the lost time through sleep. Although I believe taking a nap is way more beneficial than that if you’re a knowledge worker (=coder), let’s work with 2%.

2% of an average coding income of $100,000 USD yields an additional income of at least $2,000 per year. Put into the S&P 500, this yields an additional net worth of almost $400,000 USD after 30 years.

For sleeping…


Other results of similar studies are that people who take a daily nap are happier and healthier.

Not surprising results – but all the more powerful! And almost nobody is doing it!

Is it because today’s work environments have not yet caught up to the research? Maybe.

As a freelance developer, you can implement this simple habit in an instant — and make more money, be happier and healthier – just by sprinkling a little bit of sleep into your day!

Habit #3 – Go For a Morning Walk in Nature and Listen to Business Books.



There is strong scientific evidence for the benefits of daily walking, such as

? “For every 2,000 steps, risk of heart disease, cancer, and premature death decreases by 10% […]” – with some convergence at the 10,000 steps per day level.

Also, walking in nature increases your work productivity and creativity:

? “In 2014, two Stanford University researchers published some remarkable findings in a paper titled “Give your ideas some legs: the positive effect of walking on creative thinking”. […]

The results identified a clear link between walking and higher performance on the tests. In fact, compared to sitting, walking increased participants’ creative output by around 60 percent.”

Now, let’s layer in listening to business books on a daily basis while doing the walk.

From personal experience, I know that productivity goes through the roof as you keep compounding your business knowledge by reading business books.

It can easily increase your business results by double-digit percentage points every single year!

Let’s assume a mere 10% productivity increase from walking and listening to business books daily. (I think it’ll be 10 times that but let’s stay conservative).

As a freelance developer, your income will jump by $10,000 per year (or more). Over a 30-year life investing the difference in the S&P 500, yields a whopping $2,000,000 net worth.



And that’s not considering all the health benefits, reduced health costs, and increased life satisfaction when going for a walk daily.

By the way, here’s your first business audiobook, “Leaving the Rat Race with Python” (PDF + MP3). 100% free for you as a regular reader of this email academy!

? Note: This content originally came from an email sent to my coding email academy. You can signup here (free).

Summing It Up


If you implement habits (1), (2), and (3), that is, you work from home, take a nap daily, and go for a daily walk listening to business books, you can accumulate an additional fortune of $2.2M + $0.4M + $2M = $4.6M USD.





Now read again, and look how easy these habits are! Indeed, they are fun!

And your quality of life and health will improve – it may add years to your life expectancy! Low-hanging fruits, right?

To your success! ?

One Final Note


Creating my own coding business has been the best decision in my career – it set me free in an instant.

If you want to learn the strategies to succeed as a business owner of a thriving coding business online, feel free to check out my Becoming a Freelance Developer course.

It’s fun and has already changed hundreds of students’ lives!



https://www.sickgaming.net/blog/2022/11/...nce-coder/

Print this item

  (Indie Deal) Vorax Development update #1
Posted by: xSicKxBot - 11-29-2022, 05:53 AM - Forum: Deals or Specials - No Replies

Vorax Development update #1


Hi all!
Starting from this week we will give you regular updates on the Vorax development every friday.

Below are our most recent YouTube videos that will give you an idea of where Vorax is in development.


Video 1: Ambush
Vorax is for the most part an open world game where you've got miles and miles to freely explore to your heart's content.
However there are also some more tightly closed spaces, claustrophobic even, like tunnels, sewers and caves.
There the mutation has peculiar aspects depending on the environment.
Certain kind of monsters are adapting to certain type of conditions, such as light or air,
therefore some types of mutations will be specific to closed and dark spaces.


Video 2: Defending The House
The majority of the enemies, especially the toughest are photosensitive.
You must balance your physical safety and your mental sanity carefully. Finding a shelter, an appropriate location where you can hide and barricade yourself will protect you, but staying too much into the darkness will slowly chip away at your sanity. Turning on the light might offer some mental comfort, however that will also, potentially, attract unwelcomed guests.

In fact, at night the hostile creatures, mostly photosensitive, come out to hunt.
So you need to exercise extreme caution when moving around.
We have planned several buildings that can be cleared, reinforced and made into a relatively safe haven for the night.
But if these safety operations are not carried out, they can be attacked by creatures.


Video 3: Tunnel
The virus contaminates the whole island, resulting in various forms of aberrations, from small to big... to massive.
What delves deep in the dark tunnels is just one of those aberrations. Dealing with it might make both your heart and the ground beneath you tremble.


Our Vision.

We have been trying for months to work on a large game area (in the alpha indiegala for now only 15% of the island is explorable) where
we want to give the feeling of a whole environment, flora, fauna, human beings… every cell contaminated by the virus.
Because the pathogen does not affect humans exclusively, other 'entities' might be infected by the virus and the resulting mutations can be abnormal.

We also focused heavily on combat system, an aspect that had left us unsatisfied in our previous title, Die Young.
The team has placed a big emphasison ranged weapons and firearms,
which is why managing the limited ammunition available will be important to survive.
But we haven't neglected hand-to-hand combat either.
In the coming weeks we will see the use of different work tools that can turn into lethal weapons.

Compared to Die Young we think we've definitely improved the survival side.
You will be able to craft almost anything you can find in the game and
also you will be able to build a large variety of structures in order to have the most personalized gaming experience possible.

Let's keep in touch next friday.



Keep an eye on ig for updates, especially next week. On the Black Friday weekend you will be able to try out the UPDATED ALPHA[freebies.indiegala.com] build. Once more, for a limited time only.
Next weekend, infact, we will update to latest features and fixes we've been working so hard in those months.

Make sure to join us on Discord[discord.gg] for exclusive news.

Wishlist now:
https://store.steampowered.com/app/1874190/Vorax/


https://steamcommunity.com/groups/indieg...7223840456

Print this item

  PC - Among Us VR
Posted by: xSicKxBot - 11-29-2022, 05:53 AM - Forum: New Game Releases - No Replies

Among Us VR



You're used to navigating Among Us in 2D, but what if you could BE the Crewmate?

This new 3D experience will place you and our suspicious spacebeans in the heart of the Skeld, with all of the core mechanics of teamwork and betrayal you know and love. The VR edition will continue to support the multiplayer experience too, of course! Now you can really have an emergency meeting together.

(Note: VR version won't be compatible with the original Among Us game, so you'll only be able to play against other VR beans.)

Publisher: Innersloth

Release Date: Nov 10, 2022




https://www.metacritic.com/game/pc/among-us-vr

Print this item

  News - Best Team In NFL Plays GTA Online Together
Posted by: xSicKxBot - 11-29-2022, 05:53 AM - Forum: Lounge - No Replies

Best Team In NFL Plays GTA Online Together

The NFL's Philadelphia Eagles are the best team in the league right now, boasting a record of 10-1. What's the secret to their success? Lots of hard work and dedication to their craft, of course, but also a healthy amount of Grand Theft Auto.

CJ Gardener-Johnson, a safety for the Eagles, told The New York Times that he and his teammates play GTA Online during their downtime and it helps improve chemistry. "It's kind of like our secret sauce," he said.

In addition to Gardener-Johnson, defensive backs Darius Slay and Avonte Maddox join in, along with linebackers Haason Reddick and Shaun Bradley. Offensive tackle Jordan Mailata plays, too.

Continue Reading at GameSpot

https://www.gamespot.com/articles/best-t...01-10abi2f

Print this item

  [Oracle Blog] Java is alive at Oracle Code One!
Posted by: xSicKxBot - 11-27-2022, 08:22 PM - Forum: Java Language, JVM, and the JRE - No Replies

Java is alive at Oracle Code One!

The second annual Oracle Code One conference will soon be here. Again, it will showcase a wide and deep variety of developer technology initiatives Oracle is investing and participating in…from machine learning to artificial intelligence, autonomous database to microservices, and of course the Cloud...


https://blogs.oracle.com/java/post/java-...e-code-one

Print this item

 
Latest Threads
Shein Coupon & Promo Cod...
Last Post: udwivedi923
6 hours ago
"Updated" Shein Coupon & ...
Last Post: udwivedi923
6 hours ago
"Updated" Shein Coupon & ...
Last Post: udwivedi923
6 hours ago
[40% OFF 【Shein Coupon &...
Last Post: udwivedi923
6 hours ago
[$200 OFF 【Shein Coupon ...
Last Post: udwivedi923
6 hours ago
[$300 OFF 【Shein Coupon ...
Last Post: udwivedi923
6 hours ago
[$50 OFF 【Shein Coupon &...
Last Post: udwivedi923
7 hours ago
"Updated" Shein Coupon & ...
Last Post: udwivedi923
7 hours ago
{SPECIAL} Shein Coupon Co...
Last Post: udwivedi923
7 hours ago
{SPECIAL} Shein Coupon Co...
Last Post: udwivedi923
7 hours ago

Forum software by © MyBB Theme © iAndrew 2016