Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Move a key:value in a dictionary
Post: RE: Move a key:value in a dictionary

Thank you all. Worked like a charm. In appreciation, David
dgrunwal General Coding Help 4 349 Feb-24-2021, 02:43 PM
    Thread: Move a key:value in a dictionary
Post: Move a key:value in a dictionary

I created the following dictionary and added another key:value. >>> super_hero_names = { ... 'Superman' : 'Clark Kent', ... 'Spiderman' : 'Peter Parker' ... } >>> >>&g...
dgrunwal General Coding Help 4 349 Feb-23-2021, 09:17 PM
    Thread: Behavior of Abstract Base Class
Post: RE: Behavior of Abstract Base Class

Thank you. I read the PEP https://www.python.org/dev/peps/pep-3119/ and it answered my question. I was not seeing the super() clear enough. I don't have a particular use case for using abstract b...
dgrunwal General Coding Help 4 507 Oct-15-2020, 05:41 PM
    Thread: Behavior of Abstract Base Class
Post: Behavior of Abstract Base Class

All, Is this behavior correct for ABC class? I expected only the method in class S to be printed. Is this the correct behavior? import abc from abc import ABC, abstractmethod class R(ABC): de...
dgrunwal General Coding Help 4 507 Oct-15-2020, 03:12 PM
    Thread: How to append to a set in Python
Post: RE: How to append to a set in Python

Thanks, I see. Interested why the print output differs in lines 8,9. lst = [3, 3, 22, 22, 1, 4, 5, 6, 10, 20, 40, 40, 40, 50] dup_free = [] dup_free_set = {3, 3, 22, 22, 1, 4, 5, 6, 10, 20, 40, 4...
dgrunwal General Coding Help 7 716 Oct-01-2020, 03:16 PM
    Thread: How to append to a set in Python
Post: How to append to a set in Python

I am trying to append to a set and getting the following error: AttributeError: 'dict' object has no attribute 'append' lst = [3, 3, 22, 22, 1, 4, 5, 6, 10, 20, 40, 40, 40, 50] dup_free = [] dup_fre...
dgrunwal General Coding Help 7 716 Oct-01-2020, 02:18 PM
    Thread: Cannot find Python installation folder when I install Anaconda
Post: RE: Cannot find Python installation folder when I ...

In the Spyder/Anaconda console >>> import sys >>> print(sys.version) 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] >>> Also check: Tools -> Pr...
dgrunwal General Coding Help 1 635 Jul-14-2020, 03:14 PM
    Thread: Overcoming ZeroDivisionError: division by zero Error
Post: RE: Overcoming ZeroDivisionError: division by zero...

Thank you guys for looking, code working now. Much appreciation, Dave
dgrunwal General Coding Help 8 1,037 Jun-12-2020, 01:52 PM
    Thread: Overcoming ZeroDivisionError: division by zero Error
Post: RE: Overcoming ZeroDivisionError: division by zero...

Hmm, still receive ZeroDivisionError: division by zero, trying the following: from ast import literal_eval with open("C:\Dave\data.txt") as f : for line in f : name, values = line.split(...
dgrunwal General Coding Help 8 1,037 Jun-11-2020, 09:02 PM
    Thread: Overcoming ZeroDivisionError: division by zero Error
Post: Overcoming ZeroDivisionError: division by zero Err...

In the data set I have 5 such lists (all zero values). Is there a way I can eliminate this error in such cases? I could simply remove the lists, but don't want to alter the true result. from ast im...
dgrunwal General Coding Help 8 1,037 Jun-11-2020, 01:58 PM
    Thread: Formatting a Decimal to a Percentage
Post: Formatting a Decimal to a Percentage

I am new to the Python formatting - is there a function to round and print a percentage from a decimal? with open("C:\file\data.txt") as f : for line in f : name, values = line.split(' =...
dgrunwal General Coding Help 2 955 Jun-05-2020, 03:16 PM
    Thread: Reading Multiple Lists Using SUM function
Post: RE: Reading Multiple Lists Using SUM function

Bingo buran - thanks all, BTW this is the coolest python forum. :)
dgrunwal General Coding Help 6 1,093 Jun-03-2020, 08:23 PM
    Thread: Reading Multiple Lists Using SUM function
Post: RE: Reading Multiple Lists Using SUM function

It's a text file with 259 identical lists like so. p8262 = [331, 83, 112, 111, 21, 67, 8] p8264 = [384, 84, 119, 74, 28, 51, 6] p8401 = [330, 114, 217, 81, 11, 52, 5] ... print(f"The sum of p826...
dgrunwal General Coding Help 6 1,093 Jun-03-2020, 07:16 PM
    Thread: Reading Multiple Lists Using SUM function
Post: RE: Reading Multiple Lists Using SUM function

Thanks! That works. Is there a way to read and loop through a file? Have around 300 lists.
dgrunwal General Coding Help 6 1,093 Jun-03-2020, 01:40 PM
    Thread: Reading Multiple Lists Using SUM function
Post: Reading Multiple Lists Using SUM function

Hello, Here is the code I am trying to improve - can longer lists be read from a file and looped through and printed? p8262 = [331, 83, 112, 111, 21, 67, 8] p8264 = [384, 84, 119, 74, 28, 51, 6] ...
dgrunwal General Coding Help 6 1,093 Jun-02-2020, 09:47 PM

User Panel Messages

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