Re: [Tutor] Code for python game

2016-10-12 Thread Derry, James R
hi, tracey, are you allowed to use python sets? if so, you should take a look at them and their methods: https://docs.python.org/3.5/tutorial/datastructures.html?highlight=data%20structures#sets best, james From: Tutor

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread hell gates
You can write your own str.split or just use while loop. 12.10.2016, 15:12, "LQ Soh" : To whom it may concern, Can someone enlighten me as to how you can create a function such that sum_numbers('10 5 8'), when run, will give an answer of 23, without

Re: [Tutor] Code for python game

2016-10-12 Thread Alan Gauld via Tutor
On 12/10/16 18:40, tracey jones-Francis wrote: > I want to have a function that will ignore certain words that > i have specified in a dictionary. > the dictionary is called skip_words and has about 20 different strings in. We shouldn't care inside the function what the external data is

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread Alan Gauld via Tutor
On 12/10/16 17:58, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: > Sorry, I did not read the conditions that split and for should not be used. It is even more confusing - split() may NOT be used but 'for' MUST be used... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/

[Tutor] Code for python game

2016-10-12 Thread tracey jones-Francis
Im in the middle of designing a game in python, im quite new to using it and am struggling with a certain bit of code. I want to have a function that will ignore certain words that i have specified in a dictionary. I have tried so many different types of code but can't seem to return just the

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Sorry, I did not read the conditions that split and for should not be used. regards, Sarma. On Wed, Oct 12, 2016 at 10:20 PM, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: > def string_sum(s): > total = 0 > items = s.split(" ") > for item in items: >total

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
def string_sum(s): total = 0 items = s.split(" ") for item in items: total += int(item) print(total) You can call the function as string_sum("10 4 5 ") Output will be 19. regards, Sarma. On Wed, Oct 12, 2016 at 3:22 PM, hell gates

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread isaac tetteh
def foo(x): a,b = (0,"") for i in x: if i != " ": b+=i else: print ("this is b",b) a = a + int(b) print ("this is a",a) b = "" print ("final a ",a) this should help you solve it. figure a way to add the last number. if any troubles ask again. Thanks [] From:

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread Bob Gailer
On Oct 12, 2016 4:09 AM, "LQ Soh" wrote: > > To whom it may concern, > Can someone enlighten me as to how you can create a function such > that sum_numbers('10 5 8'), when run, will give an answer of 23, without > using str.split() and using a for loop def sum_numbers(x):

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread Alan Gauld via Tutor
On 12/10/16 01:37, LQ Soh wrote: > To whom it may concern, > Can someone enlighten me as to how you can create a function such > that sum_numbers('10 5 8'), when run, will give an answer of 23, without > using str.split() and using a for loop I'm assuming this is some kind of classroom exercise?

Re: [Tutor] Need help

2016-10-12 Thread Alan Gauld via Tutor
On 12/10/16 09:03, niraj pandey wrote: > Can you pls guide how to print this screen (Attached here) content in > printer ? As we already pointed out this is a text list so attachments are usually stripped off... However, printing from Tkinter is not easy. The simplest way is usually to create

[Tutor] Adding numbers within a string

2016-10-12 Thread LQ Soh
To whom it may concern, Can someone enlighten me as to how you can create a function such that sum_numbers('10 5 8'), when run, will give an answer of 23, without using str.split() and using a for loop ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Need help

2016-10-12 Thread niraj pandey
Hi , I need one more help related to printer. Can you pls guide how to print this screen (Attached here) content in printer ? Thanks Niraj On Tue, Oct 4, 2016 at 12:21 PM, niraj pandey wrote: > Ok I got it from the solution you provided on your previous mail. > >