本文共 534 字,大约阅读时间需要 1 分钟。
Codewars第三天–Create Phone Number
Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.
Example:
create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) # => returns “(123) 456-7890” The returned format must be correct in order to complete this challenge. Don’t forget the space after the closing parentheses!def create_phone_number(n): #your code here return "({}{}{}) {}{}{}-{}{}{}{}".format(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9])
转载地址:http://lmmws.baihongyu.com/