Question: The genres column contains the genres that are present in the games. It has all the genres written together without any space or special characters. Whatever is the major genre of the game is given first, followed by the other genres. For better understanding refer to the table below. Game Genres A ActionComedyAdventure B AdventureComedy C NarrationShooting
In the above table, the major genres for the Games A, B and C are Action, Adventure and Narration respectively.
Your job is to extract the major genre for each game and store it in a new column and name the column as “Major Genre”. (Hint: All the genre name starts with uppercase).
I want to split the word "ActionAction-AdventureShooterStealth" into a list of words in the below format
['Action', 'Action-Adventure', 'Shooter', 'Stealth']
I tried the below approach but didn't work out
text = "ActionAction-AdventureShooterStealth"
res = text.split(',')
print(res)
One way to do this is with
re
, where it will matches "Action" followed by zero or more occurrences of-[A-Za-z]+
i.e-
,capital
andlowercase
characters.Output: