Convert to int even with symbol occurring
This is my code import re i=input("Enter text:") ot=0 ctl=i.split() print(ctl) if re.findall(r"--\d",i): ot=int(i) print(ot) What I need to do is that I want to convert to int even with this symbol occurring getting no errors. How can I do it ?
mmaos QQQ , to create a new question you can do: > go to the *create section* (bottom of page) > select *discuss* (top of page) > click *+ new post* button
U14known , pease make an input sample and what you are expecting as output.
U14known , the "--" that you have use are 2 *HYPHEN MINUS* (unicode id / ascii 45). is this what you have meant?
U14known , I improved your code a bit I hope this is what you wanted import re, string letter=list(string.ascii_lowercase) str_in = input() cap = str_in[:2] == "--" sp = int(re.findall(r"\d+",str_in))-1 if cap: print(letter[sp].upper()) else: print(letter[sp]) https://code.sololearn.com/cncy8PiCii50
Convert to int even with symbol occurring This is my code import re import string st=list(string.ascii_lowercase) i=input("Enter text:") ot=0 ctl=i.split() print(ctl) if re.findall(r"\--\d",i): ot=int(i) print(st[ot]) Input:12 Output:l
The output is a list of int though. https://code.sololearn.com/cLe5suunzki8/?ref=app
Thank you everyone for answering and helping. There's just one final issue Try to write the code like this: Input:12 --13 Output: l M This should give me 2 letters .
Thank you all for helping. Thank you Lochard. Your code worked
When I execute this code, because the -- is here the letter should be capital
Nope. I mean I've written number 12 as mentioned in the input but added -- before it. So the input now will be like this Without -- input:12 Output:l With -- input:--12 Output:L
How to add question? I can not see button to add that
mmaos QQQ do you know how to create a code ?
Or any number of letters I need
https://code.sololearn.com/cr8O71LhYPAl/?ref=app This is my code.
Make sure to read the comments, they will help
What's wrong? :(
Why won't my image display
I have made a calculator in which my % (Percentage) not work correctly for 100%50 or 100%20.
How the answer is 50?
Number of Ones ( C++ ) question!