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
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. 🙂
+ 9
vardaan raj singh I think you must be using Python 2.x yes? raw_input() was renamed input() in Python 3.0
+ 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
+ 1
yep !