Python newbie question!

If this is a wrong forun, please give one!!

I start learning Python just 2 days ago, so i think the question is really stupid. Here it goes.

Numero = raw_input ("Escreve um numero")

def detecta_erro(Numero):
    if int(Numero) == 1: # I thaught this was a boolean, but ok just with number 1
        correcto = int(Numero)
        print type (correcto)
        return correcto
        print "Nao e um numero"

print detecta_erro(Numero)

  1. How do i make a boolean to detect if the user is writing a mumber or a string?

  2. Even in the #comments, Python doesn’t accept (é, ã), can i force it?

I already search in Python documentation, but there are so many things in there, that i’m still lost.

Thank you very much!!

  1. Numero.isdigit() will return true when all characters in the string are digits (also false if the string is empty)

  2. no


isdigit() is a Function, right? From what Module?
How do i get information from the interpreter about a function or a module?

Sorry if i’m pushing to much. :-?

thank you!!!

isdigit() is a builtin method of strings.

To get more info on something try doc.

In your example Numero.doc would return somthing like:

'str(object) -> string

Return a nice string representation of the object.
If the argument is a string, the return value is the same object.'

The help() function is also useful (though it may result in information overload).

At the ‘help>’ prompt try:

I also started learning Python recently through a free class at my college. Here’s the reference we are using:

Thank you very much. :smiley:
Learn how to program it’s very dificult if you have just one or two books for guide. Everyone thinks diferent and, if you have diferent places to get information, it’s easier to understand some things in one place, others in other place.
I saw somewhere (here on in this link ( ) and started here, but i think this book touch alot of points, but very soft in each one.

Your PDF came just in time!!!

Thank you again!!

ps- If i saw some more places with concise information, i’ll post it here.

Here it go more links about Python!
They look fine. (advanced, is not finished, but already as alot to investigate) (this one have a bit of Tkinter “Python GUI” also)