**Error: **
... value in for loop must be numeric or character

increment of for loop must be numeric

increment when looping over characters must be an integer

final value in for loop must have same type as initial

There are three allowed types of
**for**
statement.

The first is a loop over numerical values, where the
**from**
,
**to**
and
**by**
parts, if present, must evaluate to numeric values: integers, fractions or floats. Non-numeric constants such as
**Pi**
or
**sqrt(3)**
are not allowed: in some cases you might use
**evalf**
to make such a constant into a float.

The second type is a loop over character values (strings of length 1). The
**from**
and
**to**
parts evaluate to characters. The
**by**
part, if present, must be an integer.

The third type is a loop over the members of a list or set, or operands of some other expression.

These error messages arise when the expression in a
**from**
or
**to**
part of a
**for**
statement does not result in a value of type
**numeric**
or a character (a
**string**
of length 1). The allowed numeric values are integers, fractions and floats. If the actual value is a real constant but not an integer, fraction or float, you could use
**evalf**
to make it into a float.

**Examples:**

`> `
**for i from a to 3 do print(i) od;**

Error, initial value in for loop must be numeric or character

`> `
**for i from 1 to sqrt(10) do print(i) od;**

Error, final value in for loop must be numeric or character

`> `
**for i from 1 to evalf(sqrt(3)) by sqrt(2) do print(i) od;**

Error, increment of for loop must be numeric

`> `
**for i from evalf(sqrt(2)) to evalf(sqrt(10)) by evalf(sqrt(3)) do print(i)
od;**

`> `
**for i from "a" to "z" by 1/2 do print(i) od;**

Error, increment when looping over characters must be an integer

`> `
**for i from 1 to "d" do print(i) od;**

Error, final value in for loop must have same type as initial

`> `
**for i in F(a,b,c) do print(i) od;**

**See also: **
__for__
,
__evalf__
,
__numeric__

**Maple Advisor Database**
R. Israel, 1997