Login Register






where is it filter_list
Author
Message
RE: where is it #21
You said the problem is solved hence I am closing this thread
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: where is it #22
Thread re-opened @Anima Templi wanted to add something in.

Reply

RE: where is it #23
(06-18-2014, 02:23 PM)root@localhost Wrote:
(06-18-2014, 02:22 PM)Hatemind Wrote:
(06-18-2014, 02:02 PM)root@localhost Wrote:
(06-18-2014, 02:00 PM)chmod Wrote: Then it would appear that Python is working correctly. I think the problem is with your code. My Python is a little rusty so perhaps @Ex094 or even @Anima Templi would be in a better position to help, but from the looks of it the function is not being used correctly try something like

Code:
welcome = raw_input('welcome to hackcommunity ') lol = raw_input('This is just a test ') def hack_community(welcome, lol): print welcome + " " + lol hack_community(welcome, lol)

running this gives the following output:
Code:
welcome to hackcommunity hi This is just a test ok hi ok


Nope, says it has a syntax error

CHeck the indentation, and also you may need to use input instead of raw_imput, depending on your version of python. also, ints and strs don't concatenate, so you may have to use the str function to do so.


The error was on

Code:
print welcome + " " + lol

@chmod Updated it

Did you input a number to welcome or lol? That's all I can think of, but too tired to think deeper than that.

Reply

RE: where is it #24
Lol, thanks @bluedog.tar.gz.

I'm happy that Python finally seems to be running smoothly on your system. That's great. As for which version to use, I'll recommend Python 3.4. Python 3.x is the future, hence no reason to learn an already deprecated version(s). Also, if you were to go back and code in 2.x it will be easier when you already know 3.x. The trip from 2.x to 3.x is harder than 3.x to 2.x.

1. Variable naming. Please try to use describing variable names. Pick names which gives an idea about what kind of information/value the variable holds.

2. Python uses indentation, which is why your function is not ran. You put our function call inside your function, how would python know, how to run the function, when it doesn't get a call to it?

3. You use string concatenation, that's generally a bad practice and string formatting is highly recommended. I'll give you an example of how I would have wrote your code.

Code:
def greet_user(): name = input('Please enter your HC username: ') # The user is asked to enter his HC username. print ('Welcome to HackCommunity, {!s}.'.format(name)) # We use string formatting to display a nice welcome message. greet_user() # The function get's called. Notice how it's placed outside the function.

Don't mind the backslashes, the syntax highlighting script is apparently inserting escape characters...

Reply