# how can i write my coding in Function method?

Page 1 of 1

## 1 Replies - 431 Views - Last Post: 03 May 2011 - 02:58 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=230391&amp;s=8d35008ab9d6b0a61a128fe0e8d76542&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 successfulangel

Reputation: 0
• Posts: 7
• Joined: 03-May 11

# how can i write my coding in Function method?

Posted 03 May 2011 - 12:59 AM

i want some idea to write my coding in Function style.and i also want to know how to use isdigit()function when i check my error.I hope i can get some clue to change my coding style.Thanks in advance.

#### Attached File(s)

Is This A Good Question/Topic? 0

## Replies To: how can i write my coding in Function method?

### #2 Eric115

• coderさん

Reputation: 63
• Posts: 698
• Joined: 19-January 09

## Re: how can i write my coding in Function method?

Posted 03 May 2011 - 02:58 AM

Ok, first of all using the isdigit() function should be fairly easy. The isdigit() just takes a string and tells you if all of the characters in the string are a number. It will return a bool. For example
```>>> a = 'abc'
>>> b = '123'
>>> print a.isdigit()
>>> False
>>> print b.isdigit()
>>> True

```

As for using functions in your code, you could use a different function for each keyboard response. For example (this is you code just modified)
```...
elif response=="V":
scores = getscores()
print scores
...
def getscores():
scores = """"""
f=open("score.txt",'r')
for line in f:
scores += line+'\n'
return scores

```

That is a very simple example of how to put in a function with return.
I hope that is what you mean by 'function style'
Hope I could help