Python Forum
'Looping' does not work out within a 'for Loop'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'Looping' does not work out within a 'for Loop'
#2
Unindent line 18-21 - that will solve your problem.
Read PEP-8 - that will help you to write Pythonic code.

(Sep-15-2018, 04:07 PM)Placebo Wrote: 1.) How this little program knows whicch number it has defiend as the secretnumber that is to guess?
I see only that within the code a range is defined, of where the secretnumber lies, but I do not see an exact determined value?

2.) Is 'guessesTaken' somehow an already defined value in python?

  1. Returned by call to random.randint
  2. Of course not, among many reasons - it's un-Pythonic Tongue
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Messages In This Thread
RE: 'Looping' does not work out within a 'for Loop' - by volcano63 - Sep-15-2018, 04:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Questions about while loop - why does one work, and the other variant does not Swgeek 2 1,033 Aug-29-2024, 07:57 AM
Last Post: Swgeek
  While Loop Does Not Work Properly mactron 4 2,114 Jun-22-2023, 01:04 AM
Last Post: mactron
  "while" loop is looping back too early mangurian 1 1,945 Jan-28-2022, 09:15 AM
Last Post: ibreeden
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 3,197 Dec-18-2021, 02:38 AM
Last Post: knight2000
  How can this for loop work without : ? Pedroski55 1 2,387 Dec-13-2020, 01:19 AM
Last Post: palladium
  Please help my while loop does not work as expected KingKhan248 6 4,010 Sep-28-2020, 09:12 PM
Last Post: deanhystad
  While loop keeps looping mcoliver88 3 3,232 Jul-29-2020, 12:48 PM
Last Post: buran
  Nested for loop not looping puttingwordstogether 0 2,441 Jun-16-2020, 11:15 PM
Last Post: puttingwordstogether
  while loop will not stop looping TheTechRobo 5 5,716 Apr-20-2020, 01:47 PM
Last Post: TheTechRobo
  For loop in my __init__ doesn't work as expected Jessy 2 3,191 Nov-18-2019, 10:07 AM
Last Post: buran

Forum Jump:

User Panel Messages

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