pytudes._2021.coderbyte.string_challenge__medium

https://coderbyte.com/information/String%20Expression

Description:
  • For this challenge you will convert a string of written numbers to an

actual number.

Module Contents

Functions

StringChallenge(strParam)

Returns the evaluation of the arithmetic expression in a given string

pytudes._2021.coderbyte.string_challenge__medium.StringChallenge(strParam)[source]

Returns the evaluation of the arithmetic expression in a given string

Args:
strParam:

the input string containing the given arithmetic expression. Concretely, strParam contains the written out version of the numbers 0-9 and the words β€œminus” or β€œplus”.

Returns:

The string representation of the arithmetic evaluation of strParam using the written out version of the numbers 0-9. If a negative number was produced, the number is prefixed by the word β€œnegative”.

Examples:
>>> # 10 + 8 =>
>>> StringChallenge("onezeropluseight")
'oneeight'
>>> # 18
>>> # 1 - 11 =>
>>> StringChallenge("oneminusoneone")
'negativeonezero'
>>> # -10
>>> # 46 - 22 + 10 =>
>>> StringChallenge("foursixminustwotwoplusonezero")
'threefour'
>>> # 34
>>> # Empty string (degenerate case)
>>> StringChallenge("")
'zero'
>>> # 0
Parameters:

strParam (str) –

Return type:

str