['Today',' is','Breakfast',' is','Eat','Ta'] and ['Noun','Particle','Noun',' Particle','Particle',' Auxiliary verb I want to create a program that outputs the previous word when there is a particle when there are two lists called'].
What I triedmasters = ['Today',' is','Breakfast',' Eat',' Ta']
part = ['noun','particle','noun','particle','verb','auxiliary verb']
m_with_p = list (zip (masters, part,))
I don't know under what conditions I should write after this.
I would be grateful if you could teach me.
-
Answer # 1
-
Answer # 2
I think there are various things, but for example, using enumerate to turn part in a for statement, for an index whose element is a'particle', that index-the first element is brought from masters.
How to use Python, enumerate: Get list elements and indexes* When asking a question, it is better to write as much as you can and ask a question such as "an error occurred" or "the behavior is different from what you expected". Because it can be regarded as a round throw.
Related articles
- python - i can't send multiple images with the line api
- i want to perform multiple processes with else in python list comprehension notation
- python - about multiple processing and loop processing in discordpy
- python - cannot inherit a class with multiple arguments
- python - how to load multiple time formats with pandas
- python multiple regression analysis statsmodelsformula
- python - randomly extract data from multiple data frames (no between data frames is the same)
- python outputs a graph of approximation error with euclidean distance (2)
- python 3x - how to specify multiple conditions with a regular expression
- (python) i want to convert multiple json files with different columns into one csv format
- python outputs a graph of approximation error using euclidean distance
- python - [tkinter] multiple selectable combobox
- python - i want to make a total value of channels with multiple images
- python opencv face recognition multiple person image
- python - if you create multiple signup screens with django, you want to change the redirect destination in case of an error
- [python] [tkinter] i want to get multiple checkbox values
- i want to output multiple lines of html code using python
- python - i want to make the header one row after pivoting with multiple columns in pandas
- python - read multiple audio files (wav files)
A list comprehension of the answers that have already been given.
If there is a "particle" at the beginning of part, if it is as it is
masters [-1]
Since the element at the end of the list is obtained with, the conditional operator is used to return None.