Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Daron Anderson
2,567 PointsI am having weird trouble with a simple piece of code here.
def func(do1): do1 = do1.upper() do1 = len(do1) print(do1) func("this should be uppercase")
(Only the length of the string is being printed and the uppercase string is not can someone please provide some insight) Thanks Community!
2 Answers
KRIS NIKOLAISEN
54,974 PointsYou are reassigning do1 to the length so it has taken on a new value. The following prints both the uppercase string and the length
def func(do1):
do1 = do1.upper()
print(do1)
do1 = len(do1)
print(do1)
func("this should be uppercase")
Daron Anderson
2,567 PointsI appreciate the help KRIS! Thank You! and Happy Holidays.
Daron Anderson
2,567 PointsLOL wait was was redoing it and I re-read your answer I was like ohh crap i did reasign it, He was saying t5hat in the videos.
Daron Anderson
2,567 PointsDaron Anderson
2,567 Pointsthe code also produces no error.