📢
13

Just realized my variable names were confusing me in a simple script

I was writing a Python script to add up some numbers for a hobby project. I used short names like 'a' and 'b' and later forgot what they stood for. How do you make sure your variable names are clear when you're new to coding?
3 comments

Log in to join the discussion

Log In
3 Comments
the_kim
the_kim3mo ago
My early coding days were full of vague variables like 'a' and 'b'. Switching to descriptive names, such as 'total_sales' or 'customer_count', saved me hours of debugging. Have you tried using full words instead of abbreviations?
2
hugow30
hugow302mo ago
Yeah but where do you draw the line? Like, is 'cust_count' okay or is that still too short? I mean, I get the idea but sometimes you're just writing a quick loop and 'i' is fine. Idk, maybe it's just me but I feel like super long names can make the logic harder to follow sometimes, not easier.
6
jakep24
jakep243mo ago
Why waste time on long names? Code works either way.
3