Python Forum
For loops returning wrong output
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For loops returning wrong output
#1
I got a project going and it seems to give me an error.Im looking for the output of
a list what dict_subset returns. such as [{a:'Tim',b:'charlie','beta'},{a:'charlie',b :'Tim',c : beta}],and so on. this is the code.
    import string
    import random
    
    
    
    subset_list = [['charlie', 'Tim', 'beta'], ['Tim', 'charlie', 'beta'], ['beta', 'Tim', 'charlie'], ['Tim', 'beta', 'charlie'], ['charlie', 'beta', 'Tim'], ['beta', 'charlie', 'Tim']]
    dictionary_of_completed_values = []
    dict_subset = {}
    
    for every in subset_list:
            i = 0
            for each in every:
                dict_subset[string.ascii_letters[i]] = each
                i += 1
                dictionary_of_completed_values.append(dict_subset)
    
    for each in dictionary_of_completed_values:
        print(each)
Yoriz write May-03-2021, 09:50 AM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
For loops returning wrong output - by Nighthound21 - May-03-2021, 03:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,587 Mar-27-2023, 07:38 AM
Last Post: buran
  Python Pandas Syntax problem? Wrong Output, any ideas? Gbuoy 2 938 Jan-18-2023, 10:02 PM
Last Post: snippsat
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,579 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  Os command output in variable shows wrong value paulo79 2 1,523 Apr-09-2022, 03:48 PM
Last Post: ndc85430
  print function output wrong with strings. mposwal 5 3,141 Feb-12-2021, 09:04 AM
Last Post: DPaul
  compiled cpython output wrong version bigrockcrasher 0 1,516 Feb-25-2020, 06:31 PM
Last Post: bigrockcrasher
  python gives wrong string length and wrong character thienson30 2 3,025 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  Wrong output in Visual Studio Code py_learner 1 2,674 Jun-24-2019, 10:02 PM
Last Post: Yoriz
  A question about subprocess taking input from command line and returning output! Aurimas 8 5,228 May-15-2019, 04:02 PM
Last Post: Aurimas
  Loops - new terminal output to file for each loop jm_ice 1 2,599 Dec-21-2018, 02:42 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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