All Questions
1,025 questions
1
vote
2
answers
76
views
Convert list of integers into a specific string format
I'm dealing with a list of integers that represent the pages in which a keyword was found. I would like to build block of code that converts this list into a string with a specific format that follow ...
0
votes
0
answers
64
views
Getting "TypeError: '<' not supported between instances of 'int' and 'str'" error when creating variable from output
I'm looking at using Ansible with the hpe.ilo collection to automate the selection of disks for the creation of logical disks in RAID arrays. I've found through testing that using CapacityMiB rather ...
-3
votes
3
answers
97
views
I want a int input varible then cnvert it to string
So i wanted to convert an int(input('Enter an integer') to str. because i wanted to code that if the user inputed a letter the python would print out this ('Error'). The reason im doing this is i was ...
-1
votes
1
answer
70
views
Find substring of digits in given string
Can not understand how parts of code works. The code should finde all digits and create int or float value, if "-" before first digit in given string, value should be with "-" sign....
1
vote
5
answers
114
views
Duplicate a line in TXT file and increase number inside it every time it duplicates
Let's say I have this line in TXT file:
ABCD1EFGH
What I want to do is repeat the line for an amount number of times but the number 1 will increase by 1 every time it duplicates.
like that:
ABCD1EFGH
...
0
votes
5
answers
114
views
How can I import data from a CSV file into lists of strings and lists of integers, at the same time?
So far I have the code I need to open a CSV file and import the data contained into several lists. However, these are all lists of strings, and I need some as lists of strings and others as lists of ...
-1
votes
2
answers
98
views
Maintain Leading Zeroes In An Integer Python
I have some code that calculates a number as a string and uses
.zfill(N)
But its later converted to an int and the zero disappears. Is there any way to keep the leading zero(es)?
An example of this ...
-1
votes
3
answers
74
views
Hi, i have problem with my code, i want to create a new list from the list
The elements of the list are integers and strings, I want to convert them to integers first, but the program ignores the command int(i) and outputs a list with the same elements as the first list.
...
0
votes
1
answer
43
views
Python | My code recognizes the number 100 on the screen via pytesseract as str, but I need to get an int
There is a number in a certain area
For example - 100
It is recognized through pytesseract (pytesseract.image_to_string) as str, but I need an int to pass the result to the calculation formula, ...
1
vote
1
answer
62
views
Assigning Integers to strings and then adding them
I'm trying to create a menu for a sandwich place as a mini project. I have most of what I need figured out, but I want to assign each menu item an integer for the price, and then add each number ...
-1
votes
2
answers
156
views
Is there a way to replace an integer in a list, with a string from another list at random?
I have a list of words which are also assigned a numerical value
words = [[Happy,1],[Sad,2],[Anger,3]]
I then have two additional lists, of just words and integers, produced in earlier code
List1 = [...
-1
votes
2
answers
66
views
How do I covert one singular string in a list to an integer
Trying to convert 12hr clock to 24hr clock. Input = 11:00 PM, output should be 23:00.
I know I have to add 12 to it when it’s PM time but to do so I need to turn the number from a string to an integer....
1
vote
0
answers
49
views
python while loop still running after a condition is met [duplicate]
I've been happily learning python over the last few days with today being much less happy. I isolated the below loop and its running even when the condition is met.
Any ideas as to why?
a = input(&...
-2
votes
1
answer
96
views
How to convert a string column containing a '$' and ',' to integer type [duplicate]
I'm trying to plot a dataframe in pandas. There is a price column in the dataframe containing the $ sign and floating numbers. Now if I convert it to int through car_sales\["Price"\]= ...
0
votes
1
answer
70
views
Filter strings in a list for for numbers at specific index
I am filtering through a text project of rearranging addresses from other texts. I have a list I am calling rest. Each list is a different address and description on a new line of text.
I want to copy ...