Python Forum
Some line code explanation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some line code explanation
#1
Hello I am new to python and I still get confused in some parts. I have this code that I want to understand. I can understand most of it but I get confused on lines 6 up to 11.
winningSet =  (10, 11, 8, 1, 5, 20)

numberInput=tuple(input().split())
d = {}
winningPrize = 0
f = 1

if(len(numberInput) == 7):
    for i in range(1,7):
        if int(numberInput[i]) in d:
            f = 0
            break
        else:
            d[int(numberInput[i])] = 1
        if(int(numberInput[i]) in winningSet):
            winningPrize += 100
    if f:
        if winningPrize != 0:
            print(numberInput[0],"won", winningPrize ,"pesos!")
        else:
            print(numberInput[0],"won nothing!")
    else:
        print("No Duplicates")
else:
    print("Should be 6 numbers") 
Reply


Messages In This Thread
Some line code explanation - by Chrilo06 - Feb-24-2022, 03:57 AM
RE: Some line code explanation - by ibreeden - Feb-24-2022, 11:16 AM
RE: Some line code explanation - by Chrilo06 - Feb-24-2022, 02:53 PM
RE: Some line code explanation - by deanhystad - Feb-24-2022, 06:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  New learner in Python, and need help on the term explanation BaicaiPy 3 1,328 Oct-15-2022, 03:31 PM
Last Post: Yoriz
  XOR solution explanation needed. omm 7 3,275 Oct-26-2020, 06:30 AM
Last Post: omm
  While statement explanation alkhufu2 3 2,425 Sep-02-2020, 05:46 PM
Last Post: alkhufu2
  How to repeat input line of code until condition is met Reta 2 3,418 May-14-2019, 10:06 PM
Last Post: nilamo
  Python code unable to show Bokeh line chart kirito85 2 2,549 Feb-06-2019, 07:52 AM
Last Post: kirito85
  Output explanation AmanTripathi 2 2,856 Feb-14-2018, 03:03 PM
Last Post: AmanTripathi
  need help with some explanation vincelim99 2 3,665 Mar-24-2017, 04:12 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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