Answer the question
In order to leave comments, you need to log in
How to give new attributes to elements in a list?
Hello.
There is a folder with *.wav files and there is a variable that includes all these files as a list - soundX = glob.glob("*.wav")
How to correctly access this list by element in order to extract this element for playback?
Like this:
sound4 = pygame.mixer.Sound(path.join(any_dir, 'Powerup.wav'))
sound4.play()
Answer the question
In order to leave comments, you need to log in
Resolved the issue.
# импортируем необходимые модули (есть лишние)
import pygame
import random
import shutil
import os
from os import path
import glob
pygame.mixer.init()
# указываем папку где находятся файлы *.wav
any_dir = path.join(path.dirname(__file__))
# Создаем переменную-список, в которые фойдут файлы *.wav
soundX = glob.glob("*.wav")
#Собственно сам цикл, который преобразовывает
for items in range(len(soundX)):
soundX[1] = pygame.mixer.Sound(path.join(any_dir, 'Powerup.wav'))
soundX[1].play()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question