anonymous
  • anonymous
What is wrong with my python code? Mooc 6.189 user_input = int(raw_input('enter integer here: ')) print ' you entered the value', user_input while abs(user_input) > 0: abs(user_input) = abs(user_input) - 1
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
You cannot attribute value to an expression... ie : abs(user_input) is invalid. If you want to take care of negative values, you should probably do something like user_input = abs(user_input) before the loop...
anonymous
  • anonymous
btw, you could just modify abs(user_input) = abs(user_input) - 1 by user_input = abs(use_input) - 1 but after the first iteration, all abs() operation would be useless, as the number would have been converted to positive at first loop...
anonymous
  • anonymous
So this is a better code? user_input = int(raw_input('enter integer here: ')) print ' you entered the value', user_input while abs(user_input) > 0: if user_input < 0: user_input = user_input + 1 print user_input else: user_input = user_input - 1 print user_input

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Sure, much better like this !

Looking for something else?

Not the answer you are looking for? Search for more explanations.