Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Conversion of ['a', 'b'] to { 'letter': 'a,b' }
Post: RE: Conversion of ['a', 'b'] to { 'letter': 'a,b' ...

1st step: convert ['A','B'] to a single string with a comma like 'A,B' 2nd step: create a new dictionary with key = letter, value = 'A,B'
naughtyCat General Coding Help 2 310 Sep-13-2021, 03:30 PM
    Thread: is and '==' i'm confused
Post: RE: is and '==' i'm confused

is is used to determine whether two variable reference objects are the same (same memory address) == is used to determine whether the value of the reference variable is equal (same value but different...
naughtyCat General Coding Help 6 646 Sep-13-2021, 08:47 AM
    Thread: New to python and need help with spacing
Post: RE: New to python and need help with spacing

what u need to do is double up the "\" string = """GIS GIS GIS GIS GIS GIS GIS GIS\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\GIS GIS\\\\\\\\\\\\\\\\\\GIS\\\\\\\\\\\\\\\\\\GIS GIS\\\\\\\\\\\\\\\\\\\\\\\...
naughtyCat General Coding Help 12 817 Sep-12-2021, 04:35 AM
    Thread: Functions: Recursion
Post: RE: Functions: Recursion

def sequence(n: int): print(n) if n <= 0: return sequence(n-5) sequence(16)Output:16 11 6 1 -4OR def sequence(n: int, arr = None): if not arr: arr = [] arr.append(n) ...
naughtyCat General Coding Help 4 462 Sep-10-2021, 03:18 PM
    Thread: changing key names in nested dict
Post: RE: changing key names in nested dict

you mean like this? entries = [] for key, value in sample['nodeinfo'].items(): if isinstance(value, dict): entries.append([key, list(value.values())]) else: entries.append([key...
naughtyCat General Coding Help 6 483 Sep-10-2021, 07:05 AM
    Thread: Add elements to a Dictionary
Post: RE: Add elements to a Dictionary

**wall** **wall** **wall** **wall** **wall** **wall** **wall** **wall** Why complicate it? mydict = dict() Title = 'Rocky'; Rating = 5 for n, i in enumerate(range(Rating, 0, -1), start = 1):...
naughtyCat General Coding Help 12 864 Sep-09-2021, 05:33 AM
    Thread: my simple code wont work! help!
Post: RE: my simple code wont work! help!

import random x, y = random.randrange(0, 10), random.randrange(0, 10) if int(input(f"what is {x} times {y}\n")) == x*y: print("Correct!!!!") else: print("Wrong answer")
naughtyCat Homework 2 532 Sep-05-2021, 09:06 AM
    Thread: array manipulation
Post: RE: array manipulation

arr1 = [0, 1, 2, 4, 8, 3, 5, 9, 6, 10, 12, 7, 11, 13, 14, 15] arr2 = [1, 0, 0, 1, 1, 1, 0, 1] arr3 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] x = len(arr1)-len(arr2) for n, i in enumerate(arr1...
naughtyCat General Coding Help 3 416 Sep-03-2021, 09:32 AM
    Thread: why don't i get the answer i want
Post: RE: why don't i get the answer i want

def answer(cards: list) -> (bool, int): res = None def isStraight(cards: list) -> bool: nonlocal res res = [cards[0]] count = 1 cards.sort() for n...
naughtyCat General Coding Help 12 756 Sep-03-2021, 09:22 AM
    Thread: print (output)
Post: RE: print (output)

There are three ways: command = "Hello World!" print(f"my command is {command}") print("my command is %s"%command) print("my command is {}".format(command))Output:my command is Hello World! my comman...
naughtyCat General Coding Help 3 408 Sep-03-2021, 09:21 AM
    Thread: Multiple inputs on the same line (beginner)
Post: RE: Multiple inputs on the same line (beginner)

day, month, year = input().split() # input as string day, month, year = map(int, input().split()) # input as integer birthday = list(map(int, input().split())) # input as a list
naughtyCat General Coding Help 9 648 Sep-03-2021, 04:32 AM
    Thread: Getting error trying to use functions to multiply numbers
Post: RE: Getting error trying to use functions to multi...

your code is incorrect def get_user_input_1(): user_input = input('Type a number: ') return user_input # here got return def get_user_input_2(): user_input = input('Type another number...
naughtyCat General Coding Help 5 479 Aug-30-2021, 05:54 AM
    Thread: Getting error trying to use functions to multiply numbers
Post: RE: Getting error trying to use functions to multi...

this is incorrect if x or y != 'q'should be like this if x != 'q' or y != 'q'or if 'q' not in (x, y) # also correctDon’t treat the code as a human language
naughtyCat General Coding Help 5 479 Aug-30-2021, 05:42 AM
    Thread: while loop
Post: RE: while loop

arr = [] print('You can enter up to ten names') while len(arr) <= 10: # maximum 10 names flag = input('continue? y / n\n') # loop end flag try: assert flag.lower() in ('y', 'n') except:...
naughtyCat Data Science 2 429 Aug-28-2021, 03:24 PM
    Thread: I need some help with my code
Post: RE: I need some help with my code

(Feb-27-2021, 08:19 PM)SantiagoPB Wrote: def longestIncreasing(arr): res = [] temp = [arr[0]] for i in range(1, len(arr)): if arr[i] > arr[i-1]: temp.append(arr[i]...
naughtyCat Homework 5 1,383 Aug-27-2021, 04:53 PM
    Thread: Simple Method to calculate average and grade
Post: RE: Simple Method to calculate average and grade

(Aug-26-2021, 05:24 PM)deanhystad Wrote: ya, you are right, because i never check my code just now, small mistakes I shouldn't make the code should be like this: average = [95] for item in averag...
naughtyCat Homework 7 1,543 Aug-27-2021, 08:21 AM
    Thread: Displaying list correspond to the column number
Post: RE: Displaying list correspond to the column numbe...

(Apr-04-2021, 10:02 AM)danlopek14q Wrote: def func(arr, col = None): if col == None: return '' return [arr[i] for i in col] arr = ['Mars', 'Hot', 22, True] column = [0, 1] print(func(arr, c...
naughtyCat Homework 9 1,256 Aug-27-2021, 04:32 AM
    Thread: Displaying list correspond to the column number
Post: RE: Displaying list correspond to the column numbe...

(Apr-04-2021, 10:37 AM)ibreeden Wrote: (Apr-04-2021, 10:02 AM)danlopek14q Wrote: this is not correct def all_list(listas,column = []): # this is wrongfor example: def func(arr = []): print(arr...
naughtyCat Homework 9 1,256 Aug-27-2021, 04:24 AM
    Thread: Formula function (not too difficult i think)
Post: RE: Formula function (not too difficult i think)

...... **doh** **doh** **doh** def func(year): x = 100; y = 5 if year == 1: return x return (func(year-1))*y+x for i in range(1, 5): print(func(i))Output:100 600 3100 15600
naughtyCat Homework 6 1,287 Aug-27-2021, 03:49 AM
    Thread: Functions and if elif problem
Post: RE: Functions and if elif problem

... **doh** def get_season(month): season = { 'Spring': ['September', 'October', 'November'], 'Summer': ['December', 'January', 'February'], 'Autumn': ['March', 'April', '...
naughtyCat Homework 2 949 Aug-27-2021, 03:37 AM

User Panel Messages

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