Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: knowing for loop position in a list
Post: RE: knowing for loop position in a list

my_words = """I've got a text variable, my_word. I want to run a for loop For letter in my_word: if letter == "f" I want to know the index number of the letter that's being tested to see whether it'...
Yoriz General Coding Help 4 828 Jan-30-2025, 07:58 PM
    Thread: Regarding The For Loop
Post: RE: Regarding The For Loop

The for statement iterates over elements in a sequence such as a string, tuple or list) or other iterable object. The range creates a terable sequence of numbers. for i in range(1, 3): print("Hell...
Yoriz General Coding Help 5 1,629 Nov-10-2024, 08:10 AM
    Thread: python error
Post: RE: python error

I expect it is because inside mkdir(base, name) a path is only returned when if not os.path.exists(path) is true. Change the indentation so path is always returned. def mkdir(base, name): path = o...
Yoriz General Coding Help 3 1,811 Oct-26-2024, 09:44 AM
    Thread: Tkinter GUI Sleep alternative
Post: RE: Tkinter GUI Sleep alternative

The entry is created below the start button, the labels are not destroyed because destroy has not been called as there are no () at the end. Change def iamtrying(): print("Hello") spot1.destro...
Yoriz GUI 4 1,418 Oct-16-2024, 07:46 PM
    Thread: change dataclass to frozen at runtime
Post: RE: change dataclass to frozen at runtime

I think you might have to create a new frozen version of the unfrozen dataclass at the most efficient point you can in your code.
Yoriz General Coding Help 2 1,270 Oct-06-2024, 07:54 AM
    Thread: A Programmer Named Tim
Post: RE: A Programmer Named Tim

https://python-forum.io/misc.php?action=help&hid=29 Wrote:User Titles The user title is assigned to users based on post count.
Yoriz Board 3 2,136 Mar-16-2024, 08:24 PM
    Thread: casting types rewrite
Post: RE: casting types rewrite

The print line has 3 opening brackets but only 2 closing brackets, add another close bracket to the end
Yoriz Homework 3 1,738 Jan-30-2024, 11:13 PM
    Thread: unable to remove all elements from list based on a condition
Post: RE: unable to remove all elements from list based ...

Removing an item from the list while looping over it changes the index location of the remaining items. You can loop over a copy of the list and remove items from the original list values=[6.2,5.9,4....
Yoriz General Coding Help 3 1,783 Jan-27-2024, 09:43 AM
    Thread: Code test
Post: RE: Code test

The code after the import is incorrectly indented but that could just be the way you have posted it. It asks that done() is used at the end
Yoriz Homework 2 1,442 Jan-14-2024, 04:02 PM
    Thread: Text conversion to lowercase is not working
Post: RE: Text conversion to lowercase is not working

The string method replace returns a copy of the string with all occurrences of substring old replaced by new. old_text = " A B C D " new_text = old_text.replace(" A ", " a ") print(old_text) print(new...
Yoriz General Coding Help 3 1,425 Jan-13-2024, 11:21 AM
    Thread: Variable definitions inside loop / could be better?
Post: RE: Variable definitions inside loop / could be be...

The example code does not have a loop so it does not show the problem you are having doubts about.
Yoriz General Coding Help 2 1,395 Jan-09-2024, 10:51 PM
    Thread: [pandas] TypeError: list indices must be integers or slices, not str but type is int.
Post: RE: [pandas] TypeError: list indices must be integ...

In the line exercises = df.loc[ix_mg[0][1]].at[m_g[ix_mg[0][0]]]Look at this part m_g[ix_mg[0][0]]Not used pandas in a while is that a valid input for at? Looking at https://pandas.pydata.org/docs/re...
Yoriz Data Science 4 3,431 Dec-29-2023, 10:19 PM
    Thread: I'm looking for the syntax of a complex exponent, like: 2 ** (n - m)
Post: RE: I'm looking for the syntax of a complex expone...

The walrus := could be used to only compute n - m only once. import itertools n = 3 m = 1 p = n - m numbers = ( (98**p) + (2**p), (98 ** (n - m)) + (2 ** (n - m)), (98 ** (result := n - m...
Yoriz General Coding Help 2 1,523 Dec-29-2023, 01:53 PM
    Thread: Strange behavior of parse_qsl when parameter value is '+'
Post: RE: Strange behavior of parse_qsl when parameter v...

The end of the parse_qsl function is using replace('+', ' ') def parse_qsl(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace', max_num_fields=None, sep...
Yoriz Web Scraping & Web Development 2 2,047 Dec-28-2023, 11:10 AM
    Thread: error occuring in definition a class
Post: RE: error occuring in definition a class

https://docs.python.org/3/reference/data...ct.__new__ Wrote:object.__new__(cls[, ...]) Called to create a new instance of class cls. __new__() is a static method (special-cased so you need not declare...
Yoriz General Coding Help 3 2,392 Nov-26-2023, 09:28 AM
    Thread: error occuring in definition a class
Post: RE: error occuring in definition a class

As per the error TypeError: object.__new__() takes exactly one argument (the type to instantiate) Change obj = super().__new__(cls, *args, **kwargs)to only pass cls obj = super().__new__(cls)
Yoriz General Coding Help 3 2,392 Nov-25-2023, 02:01 PM
    Thread: Help needed for a program using loops
Post: RE: Help needed for a program using loops

Well done, you will still be getting a blank line printed as the range will return 0, 1, 2, 3, 4. Changing the range to have a start value of 1 will skip the o giving 1, 2, 3, 4. for x in range(1, 5):...
Yoriz Homework 5 2,685 Sep-03-2023, 01:54 PM
    Thread: Help needed for a program using loops
Post: RE: Help needed for a program using loops

A range of 1 will only loop once with a value of 0. 0*"*" won't print anything n = n+1 does nothing to alter your print statement as it is only using x range can have its first parameter as the start ...
Yoriz Homework 5 2,685 Sep-03-2023, 12:50 PM
    Thread: [NEW CODER] TypeError: Object is not callable
Post: RE: [NEW CODER] TypeError: Object is not callable

I am not sure what is going on, the code you have shown doesn't look like it would give the error shown. The error states that you are calling a str object, but I cant see that you are. Edit: The cod...
Yoriz General Coding Help 5 6,048 Aug-20-2023, 11:34 AM
    Thread: problem in using pyqrcode module to create QRcode
Post: RE: problem in using pyqrcode module to create QRc...

https://pypi.org/project/PyQRCode/ Wrote:Requirements The pyqrcode module only requires Python 2.6, Python 2.7, or Python 3. You may want to install pypng in order to render PNG files, but it is optio...
Yoriz General Coding Help 9 7,006 Aug-19-2023, 03:12 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020