Last active
September 4, 2019 16:10
-
-
Save mrcrnkovich/c0f81baa1653ce6a331714eece3cec0c to your computer and use it in GitHub Desktop.
Codewars kata: Calculate mean and concatenate string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Return an array of length 2 with a[0] representing the mean of the ten integers as a floating point number. | |
| There will always be 10 integers and 10 characters. Create a single string with the characters and | |
| return it as a[1] while maintaining the original order. | |
| """ | |
| def mean(lst): | |
| #split list into integers and strings | |
| lst_mean = [int(i) for i in lst if i.isdigit()] | |
| lst_str = list(filter(lambda x: not x.isdigit(), lst)) | |
| #return arr[float, str] | |
| return [sum(lst_mean)/len(lst_mean), ''.join(lst_str)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment