From 275703931fa628cbddeb98a68cbfa8a7da7bed89 Mon Sep 17 00:00:00 2001 From: shinra1012 <60030961+shinra1012@users.noreply.github.com> Date: Fri, 16 Jul 2021 00:24:09 +0800 Subject: [PATCH] TypeError: expected string or bytes-like object when I try to run using style_mix like given example I got TypeError: expected string or bytes-like object . I print the input:s of num_range function. I find it may get a list and raise the error. I haven't found out when it happened (num_range function get a list),but simply change makes it work. --- style_mixing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/style_mixing.py b/style_mixing.py index c47bebbc4..a52757f3f 100755 --- a/style_mixing.py +++ b/style_mixing.py @@ -24,7 +24,9 @@ def num_range(s: str) -> List[int]: '''Accept either a comma separated list of numbers 'a,b,c' or a range 'a-c' and return as a list of ints.''' - + + if type(s) is type([]): + return s range_re = re.compile(r'^(\d+)-(\d+)$') m = range_re.match(s) if m: