I'm creating a simple module that have a cin and cout functions. This will accept the user input and
display it afterwards.

Just like this:

text = napster.comein("Enter a number: ") 

I have a problem in the function code because I'm an amateur in python programming.

This is my idea:

def comein(string):
    str = string
    string = input(string)

def getout(string):
    print string

What is the correct syntax in recalling the input of the user in the comein function?
I'm really confused about that.

Recommended Answers

All 3 Replies

You need a return statement. Also, I deduce from your print statement that you're using python 2 where raw_input should be used instead of input, so it will be

def comein(string):
    return raw_input(string)

Or simply

comein = raw_input

thanks I've now quite finished my module. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.