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 (2015) Python Data Types Del

How do I define a variable and assign total to another variable already defined

How do I define a variable and assign total to another variable already defined

delete.py
current_count = 1
planned = 5
upcoming_releases = 2
del planned
def total
sum = current_count
total = upcoming_releases

1 Answer

Steven Parker
Steven Parker
208,478 Points

The "def" keyword is only used for defining functions.

New variables can be created just by assigning values to them. And you won't need a separate variable for the sum, just add the two values together on the same line as you make the assignment.