![]() |
|
where is it - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Python (https://sinister.li/Forum-Python) +--- Thread: where is it (/Thread-where-is-it) |
RE: where is it - Ex094 - 06-18-2014 You said the problem is solved hence I am closing this thread RE: where is it - bluedog.tar.gz - 06-18-2014 Thread re-opened @Anima Templi wanted to add something in. RE: where is it - Hatemind - 06-18-2014 (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 Did you input a number to welcome or lol? That's all I can think of, but too tired to think deeper than that. RE: where is it - Anima Templi - 06-18-2014 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... |