0

Can someone please help me out with this code in python

if I write the code a=list(str(input())) print(a),and enter 12-3 it should give ['1' ,'2' ,'-' , '3'] but it gives ['9'] as result, basically it works if I enter non negative integers ,but misbehaves when a negative sign is entered......I tried this in sololearn code playground and it works there but doesent in pycharm or cpython........pls help https://www.sololearn.com/discuss/1187881/?ref=app https://www.sololearn.com/discuss/1187881/?ref=app

9th Apr 2018, 9:22 AM
vardaan raj singh
vardaan raj singh - avatar
4 Answers
+ 9
Hmmm. It works fine on Pydroid3 and VS Code. BTW you never need to write str(input()) because input() always outputs a string. 🙂
9th Apr 2018, 9:56 AM
David Ashton
David Ashton - avatar
+ 9
vardaan raj singh I think you must be using Python 2.x yes? raw_input() was renamed input() in Python 3.0
10th Apr 2018, 6:09 AM
David Ashton
David Ashton - avatar
+ 1
thnx for the advice sir, btw I got it ,u r right I have to write raw_input() so that special characters are also accounted for,I tried this and it accepts it now
9th Apr 2018, 11:51 AM
vardaan raj singh
vardaan raj singh - avatar
+ 1
yep !
10th Apr 2018, 6:18 AM
vardaan raj singh
vardaan raj singh - avatar