Skip to main content

All Questions

Tagged with
0 votes
0 answers
59 views

Removing a character from [index] for index in the indexlist

I am making a simple search function which searches word matches from a list of words. Characters in the searchword should be replaceable with a ".". I, however, ran into trouble with ...
Arttu's user avatar
  • 1
-1 votes
1 answer
36 views

How to create for loop to return series of objects considering apostrophes to input into another function

Hi I have a function which looks like this... for n in results[:10]: data_frame = mda.get_unified_series( SeriesEntry('nyse_vl'), SeriesEntry('useqin0016'), ...... )....
oldradishsoip's user avatar
0 votes
3 answers
101 views

I would like to add a new line after printing an iterable in a for loop

I am playing with hangman. I loaded the word to guess into a list. I am using a for loop to print the word with spaces and the end = "" so that they print across. After all the letters ...
CoolRunningASIC's user avatar
0 votes
2 answers
119 views

Error with my code that checks if a number is a palindrome

This is my code that checks if a number is a palindrome. class Solution(object): def isPalindrome(self, x): string = str(x) idx = 0 # if the number is even; if (x %...
Coda's user avatar
  • 9
0 votes
1 answer
67 views

How do I neatly convert my data type for a "for" loop in python

I have a DataFrame (1284 rows, 22 columns) I want to make a scatter plot of each column vs the first column so I will have 21 plots. In the below "for" loop I use the columns of my DataFrame ...
Schieper's user avatar
0 votes
0 answers
55 views

Storing information from a string datafile in a vector

I want to store information from .dat file, which is in ASCII format. The file - as read by pandas - is an array where each element is a string. df = pd.read_csv(r"C: ...path to datafile") y ...
In the blind's user avatar
-1 votes
1 answer
41 views

Why is my index in my enumerate() function not functioning properly? [duplicate]

So when I'm trying to make buttons for my sidebar, I make a button for every class by using a for loop. for index, course in enumerate(api.pull_courses('insert_my_api_key_which_works')): ...
Bird's user avatar
  • 29
0 votes
2 answers
83 views

For loop in Python: continuing iteration outside the for loop

I have a function which contains a for-loop. a_laps are the times in seconds needed for a lap which is 400 metres. The function I have so far defined goes like this: LAP_DISTANCE = 400 def ...
M.J.'s user avatar
  • 1
0 votes
2 answers
447 views

I am trying to find a way to act on characters in an array in Python

I am very new to coding and Python. I am trying to change characters in string elements of an array conditional on their adjacency to another character. These characters are grouped into arrays based ...
Usergyt's user avatar
0 votes
0 answers
25 views

How can I add these if and elif statements into a single string instead of printing out each statement on its own line? [duplicate]

def main(): phoneNumber = str(input('Please enter your phone number (XXX-XXX-XXXX): ')) for count in phoneNumber: if count == '0': print('0') elif count == '1': ...
Noah 's user avatar
-2 votes
2 answers
107 views

Surprise 51 appearing in my output about a .join() function

I am doing some work for school, and trying to work with strings, lists etc. I was asked to separate my string with a "-", every 3 letters. By trying to do so, with the function .join(), I ...
Delemme's user avatar
-2 votes
1 answer
1k views

Create a List From Input Separated by Commas And Find the Sum of the List with For/While Loops

I'm new to Python and am currently working on the following problem. It seems simple but I keep getting lost in value errors. Here's the requirements: Write a program that allows the user to input as ...
basenchar's user avatar
-1 votes
1 answer
56 views

IndexError: string index out of range keep getting this can't understand how to fix it

while length > 2: if s[i].isalpha(): i += 1 i1 = i length -= 1 elif s[i].isdigit(): if int(s[i]) == 0: return False ...
Michael's user avatar
1 vote
0 answers
109 views

Why do char strings and byte strings iterate differently? [duplicate]

I've noticed something odd about for loops iterating over Python strings. For char strings, you get strings with a single character each. >>> for c in 'Hello': print(type(c), repr(c)) &...
Mark Ransom's user avatar
-2 votes
3 answers
166 views

How to save words to a new list?

For each word in words, add ‘d’ to the end of the word if the word ends in “e” to make it past tense. Otherwise, add ‘ed’ to make it past tense. Save these past tense words to a list called past_tense....
user avatar

15 30 50 per page
1
2 3 4 5
34