avatar Bite 293. N digit numbers

Write a function that accepts a list of numbers and converts them into n digit integers.

Examples:  

n_digit_numbers([1, 2, 3], 2)  => [10, 20, 30]

n_digit_numbers([8, 9, 10], 2)  => [80, 90, 10]

n_digit_numbers([-1.1, 2.22, -3.333], 3)  => [-110, 222, -333]

Note: Negative numbers should keep their negativity and calling the function with n < 1 should raise a ValueError.

 

Login and get coding
go back Beginner level
Bitecoin 2X

151 out of 160 users completed this Bite.
Will you be Pythonista #152 to crack this Bite?
Resolution time: ~56 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 6.33 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help