Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
lists in tkinter
#1
Hi,
totaly new to this python stuff
I have 2 lists
i want to be able to randomly pick one item from each list one at a time
this code doesen't do the job
( for an example first i will get dog ,then hippo,then cat and etc)
Sad
thanks

import tkinter as tk
import random
root=tk.Tk()
def rand():

    animalist1=['dog','cat','cow','horse','duck','bird']
    animalist2 = ['Hippo', 'Bat', 'Fish', 'Whale', 'Bear', 'Monkey']

    seqs = [animalist1,animalist2]
    animalrand1 = random.choice(random.choices(seqs, weights=map(len, seqs))[0])


    #animalrand1 = random.choice(animalist1)
    #animalrand2 = random.choice(animalist2)
    label.configure(text=animalrand1)
    #label.configure(text=animalrand2)
Reply


Messages In This Thread
lists in tkinter - by erock - Jun-06-2020, 10:14 PM
RE: lists in tkinter - by menator01 - Jun-06-2020, 10:34 PM
RE: lists in tkinter - by bowlofred - Jun-06-2020, 10:46 PM
RE: lists in tkinter - by erock - Jun-06-2020, 11:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,557 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,459 Mar-20-2019, 08:01 PM
Last Post: stillsen

Forum Jump:

User Panel Messages

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