Problem with input format: (SyntaxError) invalid syntax found

Hello I have folloving code

def parse (string) do
  String.split(1x1x10, "x") |> String.to_integer()|> print()

and mix throw out this error

== Compilation error in file lib/help.ex ==
** (SyntaxError) invalid syntax found on lib/help.ex:2:16:
    error: invalid character "x" after number 1. If you intended to write a number, make sure to separate the number from the character (using comma, space, etc). If you meant to write a function name or a variable, note that identifiers in Elixir cannot start with numbers. Unexpected token: x
    β”‚
  2 β”‚   String.split(1x1x10, "x") |> String.to_integer()|> print()
    β”‚                ^
    β”‚
    └─ lib/help.ex:2:16

how to avoid it?

Hey @danik292 as best I can tell this is a simple syntax error. 1x1x10 is not a string, "1x1x10" is a string, you’re missing the quotes.

2 Likes