diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-09-26 08:52:36 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-09-26 08:52:36 +0100 |
| commit | ed8b454a791ccbcd0b85ed0bd353680da5cdaee6 (patch) | |
| tree | ba4df861d6796df1b8e9e24ef62a74aa8e586e4c /challenge-184/eric-cheung/python/ch-2.py | |
| parent | 0db65395831d539073afee3e3afe76ecebb2057c (diff) | |
| download | perlweeklychallenge-club-ed8b454a791ccbcd0b85ed0bd353680da5cdaee6.tar.gz perlweeklychallenge-club-ed8b454a791ccbcd0b85ed0bd353680da5cdaee6.tar.bz2 perlweeklychallenge-club-ed8b454a791ccbcd0b85ed0bd353680da5cdaee6.zip | |
- Added guest contributions by Eric Cheung.
Diffstat (limited to 'challenge-184/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-184/eric-cheung/python/ch-2.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-184/eric-cheung/python/ch-2.py b/challenge-184/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..7baeb21441 --- /dev/null +++ b/challenge-184/eric-cheung/python/ch-2.py @@ -0,0 +1,27 @@ +
+## arrInputList = ['a 1 2 b 0', '3 c 4 d'] ## Example 1
+arrInputList = ['1 2', 'p q r', 's 3', '4 5 t'] ## Example 2
+
+arrChar = []
+arrInt = []
+
+for arrLoop in arrInputList:
+ arrSubChar = []
+ arrSubInt = []
+
+ arrSplit = arrLoop.split(' ')
+
+ for arrSubLoop in arrSplit:
+ if arrSubLoop == '0' or arrSubLoop == '1' or arrSubLoop == '2' or arrSubLoop == '3' or arrSubLoop == '4' or arrSubLoop == '5' or arrSubLoop == '6' or arrSubLoop == '7' or arrSubLoop == '8' or arrSubLoop == '9':
+ arrSubInt.append(int(arrSubLoop))
+ else:
+ arrSubChar.append(arrSubLoop)
+
+ if len(arrSubChar) > 0:
+ arrChar.append(arrSubChar)
+
+ if len(arrSubInt) > 0:
+ arrInt.append(arrSubInt)
+
+print (arrChar)
+print (arrInt)
|
