Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics All Together Now Cleaner Code Through Refactoring

Can I just not use def?

So I hate defining because i find it hard. i don't really have to use it unless if I want my code to be 'clean' right?

3 Answers

jassim Al-Hatem You cannot really avoid it as functions are really the lifeblood for a lot of programming languages especially for python. After a while you yourself become programmed into typing def. Just practice and repetition.

Ekenedilichukwu Osubor
Ekenedilichukwu Osubor
Python Web Development Techdegree Student 2,859 Points

I find that trying to implement them as you work through the challenges and projects helps tremendously! Literally wherever you can use them, whether called for or not. As long as the code runs

You have to use the 'def' keyword. It tells the interpreter that the next bits of code that it sees will be a function definition.

@tarikweekes2 so i can't really avoid it can i?

well i guess i gotta start practicing, any advice on how i should do it?

I'm really doing fine at everything else except for functions, i suck at them for some reason.