Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: queued music wont play, how to do this?
Post: queued music wont play, how to do this?

queued music wont play next, any idea on this? import pygame import time pygame.mixer.init() pygame.mixer.music.load('goodbye.ogg') pygame.mixer.music.play(1) time.sleep(1.08) pygame.mixer...
glennford49 General Coding Help 0 1,389 Nov-24-2020, 12:54 PM
    Thread: broadcasting euclidean distance error
Post: broadcasting euclidean distance error

i have this code, i tried to calculate euclidean distance on each element on list1 it throws an error if list1 has 2 elements, any idea on this? import numpy as np from scipy.spatial import distance ...
glennford49 General Coding Help 1 4,005 Nov-12-2020, 11:26 AM
    Thread: extracting second values elements only in every keys in an OrderedDict
Post: RE: extracting second values elements only in ever...

thanks, +1, this saves my day
glennford49 General Coding Help 4 2,523 Nov-12-2020, 08:22 AM
    Thread: extracting second values elements only in every keys in an OrderedDict
Post: extracting second values elements only in every ke...

i have this code, i want to extract the second values elements only in every keys in an OrderedDict, i dont want to use for loop,any idea on this ? from collections import OrderedDict regDict= Order...
glennford49 General Coding Help 4 2,523 Nov-11-2020, 12:35 PM
    Thread: making list in looping a dictionary
Post: RE: making list in looping a dictionary

(Jun-25-2020, 12:55 PM)deanhystad Wrote: Do you want a list of the dictionary keys, or do you want a list that contains the dictionary as a list? Should the end result look like this: ["glenn","ele...
glennford49 General Coding Help 9 3,580 Jun-25-2020, 02:32 PM
    Thread: making list in looping a dictionary
Post: RE: making list in looping a dictionary

i dont know what is the correct approach , for each loop or for i, i dont have any idea, all i need is to loop the dictionary to get each keys as list item users={"glenn":1,"elena":2,"mama":3} names=...
glennford49 General Coding Help 9 3,580 Jun-25-2020, 10:18 AM
    Thread: making list in looping a dictionary
Post: RE: making list in looping a dictionary

im using a dictionary instead of manually writing the list out of names , coz each values and keys has purpose on another script and i want that if I add values and keys in that dictionary, list item ...
glennford49 General Coding Help 9 3,580 Jun-25-2020, 09:54 AM
    Thread: making list in looping a dictionary
Post: making list in looping a dictionary

how to make a list out of this ? is this the right approach? users={"glenn":1,"elena":2,"mama":3} names=(list(users.keys())) for i in names: # i should become a list of each 3 keys in a dictionay ...
glennford49 General Coding Help 9 3,580 Jun-25-2020, 09:34 AM
    Thread: How to do this kind of IF STATEMENT?
Post: RE: How to do this kind of IF STATEMENT?

(Jun-16-2020, 12:55 PM)buran Wrote: or even better if any(pins): print('true') else: print('none') thanks for this, it seems easier. +1
glennford49 General Coding Help 4 2,645 Jun-17-2020, 09:45 AM
    Thread: How to do this kind of IF STATEMENT?
Post: RE: How to do this kind of IF STATEMENT?

(Jun-16-2020, 11:55 AM)menator01 Wrote: p1=1 p2=0 p3=0 p4=0 pins=[p1,p2,p3,p4] for value in pins: if value == 1: print("true") else: print("none")Output:true none none none ...
glennford49 General Coding Help 4 2,645 Jun-16-2020, 12:33 PM
    Thread: How to do this kind of IF STATEMENT?
Post: How to do this kind of IF STATEMENT?

How to do this kind of IF STATEMENT? p1=1 p2=0 p3=0 p4=0 pins=[p1,p2,p3,p4] for i in pins: if (pins has value==1) print("true") else: print("none")
glennford49 General Coding Help 4 2,645 Jun-16-2020, 10:54 AM
    Thread: NameError: name 'pins' is not defined
Post: RE: return a function error

(Jun-15-2020, 12:00 PM)buran Wrote: result_names = 'elena' dict={"glenn":1,"elena":2} def person(names): pins =dict.get(names) return pins pins = person(result_names) print(pins)you ne...
glennford49 General Coding Help 2 3,603 Jun-15-2020, 12:20 PM
    Thread: NameError: name 'pins' is not defined
Post: NameError: name 'pins' is not defined

NameError: name 'pins' is not defined result_names = 'elena' dict={"glenn":1,"elena":2} def person(names): pins =dict.get(names) return pins person(result_names) print(pins)im trying to get th...
glennford49 General Coding Help 2 3,603 Jun-15-2020, 11:50 AM
    Thread: using element on a list as condition statement
Post: RE: using element on a list as condition statement

(May-19-2020, 09:15 AM)menator01 Wrote: sum = 33 list1=[11,22,33,44,55] if sum in list1: print(f'{sum} is in list') else: print(f'{sum} is not in list')Output:33 is in listthanks for the qui...
glennford49 General Coding Help 11 5,006 May-19-2020, 09:31 AM
    Thread: using element on a list as condition statement
Post: using element on a list as condition statement

how to implement this code ? i want any value in the list1 be compared in variable sum if has , statements will follow if no , prints a string as stated below sum = 33 list1=[11,22,33,44,55] if (su...
glennford49 General Coding Help 11 5,006 May-19-2020, 09:07 AM
    Thread: count each element in a list
Post: RE: count each element in a list

(May-01-2020, 11:09 AM)anbu23 Wrote: (May-01-2020, 10:50 AM)glennford49 Wrote: how to return the exact same element found in list2? Remove len() thumbs up, this saves my day!
glennford49 General Coding Help 9 4,027 May-01-2020, 11:20 AM
    Thread: count each element in a list
Post: RE: count each element in a list

(May-01-2020, 10:47 AM)pyzyx3qwerty Wrote: (May-01-2020, 10:45 AM)glennford49 Wrote: it returns nothing since list2 has no same item from list1 it has only 3 same elements that which i want to be ...
glennford49 General Coding Help 9 4,027 May-01-2020, 10:50 AM
    Thread: count each element in a list
Post: RE: count each element in a list

(May-01-2020, 10:34 AM)pyzyx3qwerty Wrote: If you want to print the same element in both lists, you can do: for i in list1 : if i in list2 : #your codeit returns nothing since list2 has ...
glennford49 General Coding Help 9 4,027 May-01-2020, 10:45 AM
    Thread: count each element in a list
Post: RE: count each element in a list

Thanks for your response,len() just return number of item in list2 which is 2, i want if there is/are same element on each item from list2 will be printed, using list1 as comparison
glennford49 General Coding Help 9 4,027 May-01-2020, 10:37 AM
    Thread: count each element in a list
Post: count each element in a list

hi guys , i want to print same element in each item in a list, my code returns nothing except if i print list2, it should return 3 elements in first item and 2 elements in a second one list1=[10,...
glennford49 General Coding Help 9 4,027 May-01-2020, 09:37 AM

User Panel Messages

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