Help with guessing game :D

Alister alister.ware at ntlworld.com
Tue Oct 29 12:19:31 EDT 2013


On Tue, 29 Oct 2013 07:40:20 -0700, Robert Gonda wrote:
>> >> 
>> >> remember that strings are a sequence.
>> >> they can be used as iterators & sliced in the same way as lists &
>> 
>> >> tuples.
>> >> 
>> >> Let a fool hold his tongue and he will pass for a sage.
>> 
>> 
>> >> 
>> >> 		-- Publilius Syrus
>> 
>> 
>> > 
>> > Now you have confused me completely, sorry im just new to python and
>> > just learning everything :) could you perhaps give me an example? or
>> > part of the code that's missing?

>> you will probably learn more through trial & error than you will from
>> being given an answer
>> 
>> to shine some more light on my advise try the following
>> 
>> code="7689"
>> for digit in code:
>> 	print(digit)
>> 
>> does this give you any Ideas on how to proceed?
> 
> Unfortunately I'm not that sort of person, the way my brain learns is by
> experimenting, but first I need to know exactly what to write. Then I
> will play around with it and customize it to my needs, sorry to be such
> a bother guys :/ and thanks again for your help it's appreciated a lot
> :)

I wont provide the code but i will try to break the problem down into 
simple steps (this is the most important skill to develop in programming)


set the number to be guessed
get the user input
step through each digit in the input
compare to the co-responding digit in the number to be guessed
generate the required output

actually let me just expand on my earlier teaser code

does this switch on any light-bulbs for you

data='7865'
guess=input('guess')
for key,digit in enumerate(data):
	print digit,guess[key]
-- 
Watch all-night Donna Reed reruns until your mind resembles oatmeal.



More information about the Python-list mailing list