# Help with count browsing

• This post is deleted!

• posted
0

ok, lets work through this together.

in your second example, can you explain why it works? in other words, walk us through the initial conditions (count is initially set to 0), and tell us what you think will happen in each loop of the while loop. what causes the while loop to end?

• This post is deleted!

• posted
0

Nice! Here are three ways to write the same loop:

``````# Number 1
count = 0
while count < 5:
c = raw_input('Give it to me: ')
count = count + 1

# Number 2 uses +=
count = 0
while count < 5:
c = raw_input('Give it to me: ')
count += 1

# Number 3 is considered the most "Pythonic"
for count in xrange(5):
c = raw_input('Give it to me: ')
``````

• posted
0

@Pythonistapro777, I don't want to interfere here. As I have said before, Scene, is black magic to me. But from what I can see, you need to think differently here.
I will say want I think... I really hope it's correct.

Imagine you rename your ending class to DisplayResults. In your main class, you add vars to the init method like self.win, self.lose etc...
When there is a win, self.win +=1

You could update those vars in your main class, when you call your DisplayResults class, you can call it with the needed values eg. DisplayClass(result_this_time, self.win, self.draw, self.lose)

I am trying to be a little vague... Hope it helps

• posted
0

Ok, so, you identified the key parts of a finite loop: it has a set of initial conditions, something which changes inside the loop, and an ending condition which is reachable from your initial conditions.

what would happen in your example if you started count at 6?

Next, why don't you walk us through your draw() function as it relates to the loop you are working on. maybe start from when someone has just won for the first time.... what will the starting and ending conditions be for the variables involed in the loop? next, assume the player continues, and wins again. what will the starting and ending conditions be for all of the variables in your loop?

A great way to answer such a question by experiment, is to add print statements at key places in your code. for instance, if that bit of code is not working the way you expect, put

``````print 'before loop',  count, stre, streak
``````

before the loop, and

``````print 'after loop', count, stre, streak
``````

after. do these match what you expected? If not, why not?

• posted
0

@Phuket2 Lets teach the man to fish, not serve him the ปลา! 🎣

• posted
0

@JonB, ถูกต้อง. 😁

• posted
0

ป้ายดำ !!

• posted
0

Ok I stop now. I am sure he does not need a thai lesson :)but that was a difficult thai word for me, I had to ask my thai friend sitting next to me. Basically unauthorised taxis , not literally but local meaning.

Internal error.

Oops! Looks like something went wrong!