1
def romanToInt(self, s: str) -> int

This is function name and this format is used in python. I am confused why we are using this arrow and why we are using int inside paranthesis after s. Can someone explain please?

3
  • 2
    See stackoverflow.com/q/51639332/3001761. Note that "this" is a pretty terrible description for a title. Commented Mar 30, 2020 at 20:38
  • stackoverflow.com/a/21384492/635608 Commented Mar 30, 2020 at 20:39
  • In the future, please use the generic [python] tag for all python related questions. Use a version-specific tag at your discretion Commented Mar 30, 2020 at 20:45

1 Answer 1

3

They are function annotations.

-> marks the return function annotation indicating the function returns an int.

The : str indicates a string argument.

You can read more about them here.

Or, SO: What does -> mean in Python function definitions?

Sign up to request clarification or add additional context in comments.

1 Comment

Questions that you know to be duplicative should be closed, not answered. See the "Answer Well-Asked Questions" section of How to Answer, including the bullet point regarding questions that "have already been asked and answered many times before".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.