id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

konstans@stuy.edu > magicValue
prev  |  next  |  chance

Look at the ones-digit and tens digit of n. When they are the same, return the value of that digit. When they are different, return the sum of the digits. It doesn't matter if n is a single digit or more than 2 digits.


magicValue(1) → 1
magicValue(502) → 2
magicValue(11) → 1

...Save, Compile, Run (ctrl-enter)

def magicValue(n):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy