Linked Questions
21 questions linked to/from Converting a String to a List of Words?
-5
votes
1
answer
4k
views
How to convert words inputs to a list [duplicate]
I need this for my homework. I'm trying to create a a program where I ask the user for some words. I want those words to be on a list so then I can use .index to call some.
I tried to use .set or ...
-3
votes
3
answers
662
views
splitting text based on word match with python [duplicate]
I have a string and I want to split it based on word match. How can I do that?
Here is my incomplete attempt
text_ = "Sky is beautiful today"
test = "beautiful"
if test in text_:
...
-8
votes
2
answers
2k
views
How to get every word out of a string? [duplicate]
I am trying to solve a problem where I need to get every word in the sentence and sort it alphabetically. I would really appreciate some help in the matter, as I don't quite have a clue about how to ...
0
votes
1
answer
594
views
Putting the words in a string into a list [duplicate]
I'm new to python and I'm trying to take words in a string and put them into a list, but I'm having trouble.
This is what it should look like:
Input: sentence = "abcde that i like."
Output: ...
0
votes
4
answers
382
views
How can I write the whole word of the variable, in Python? [duplicate]
I want to be able to print the whole variable, or just detect it. If I run it through a for loop as I've done in the code below, it just prints the individual letters. How can it print the whole word?
...
-1
votes
2
answers
58
views
Getting a sub-string from a string? [duplicate]
Is there a way in python to extract each substring thats inside a string?
For example if I have the string
"Hello there my name is Python"
I want to take out each sub-string (or individual word) ...
0
votes
0
answers
44
views
How can I make a list out of the values of an input? [duplicate]
This is quite a simple task but I'm not sure how to do it correctly and efficiently.
What I want is the user to enter some strings and to convert those str into values of a list
Example:
input:
"...
46
votes
7
answers
149k
views
Iterating through a string word by word
I wanted to know how to iterate through a string word by word.
string = "this is a string"
for word in string:
print (word)
The above gives an output:
t
h
i
s
i
s
a
s
t
r
i
n
g
But ...
0
votes
5
answers
4k
views
Python: Is it possible to split sentence into two line?
Sentence = "the heart was made to be broken"
How to split sentence for displaying in separate lines by using Python? (4 words per line)
Line1: the heart was made
Line2: to be broken
Any advice?
1
vote
4
answers
3k
views
Extracting numbers from a sentence in python and performing calculation on it
I'm new to Python but here is the question
Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters.
Input
The input will ...
1
vote
2
answers
2k
views
How to perform pattern matching between two strings?
I want to have a good pattern matching code which can exactly match between both strings.
x = "Apple iPhone 6(Silver, 16 GB)"
y = "Apple iPhone 6 64 GB GSM Mobile Phone (Silver)"
Approach 1:
...
-2
votes
2
answers
1k
views
How to detect the words with a specific letter and return them in a list containing them
I wan to create a function which, when given a sentence and a letter, returns a list containing all words in the sentence with the said letter. I want to use a list comprehension to return the list. ...
1
vote
3
answers
709
views
How to check if a string is only made-up from a list of words?
I have a list of words:
words = ['ABC', 'CDE', 'EFG']
How to check that my string only consists words from that list? For example, 'EFG CDE' results True since both 'CDE' and 'EFG' are in words.
My ...
0
votes
1
answer
1k
views
Kivy: Getting data from .txt to listitemview
Hi senior users of python, and thank you for reading this through. I am currently trying to program an accounting application that can read and write files for users.
I have a bit of trouble when ...
-1
votes
5
answers
1k
views
how to remove first word of each string in the list and append those words into a new list [duplicate]
how do i get 1st word of each string in the list and create a new list.
list1 = ['GenX XE','GenX XM','GenX XT','GenX XMA','GenX XTA']
# this is my my list
n= len(list1)
for i in range(n):
...