Skip to content
EspañolWorkspace →

PSeInt Longitud: how many characters a text has

Counts how many characters a piece of text has, spaces included.

Template
Longitud
Open it in Codoritmo

Opens the editor with this example loaded. Run it step by step and watch the flowchart.

Worked example

A complete algorithm, ready to copy and run.

longitud-string-length.psc · 3 lines
Algoritmo Example    Escribir Longitud("hola")FinAlgoritmo

Output

Shows: 4

This is what the console shows when the example runs.

4

In a flowchart

This is how it appears in a flowchart, with the same shapes Codoritmo draws.

n ← Longitud(nombre)
Used inside a calculation. It has no shape of its own; it's used inside a calculation. Flowchart: a process rectangle reading "n ← Longitud(nombre)", with one arrow in and one arrow out.
Draw the flowchart of your own algorithm →

Template

The general form. Replace what's inside < > with your own data.

Longitud · 1 line
Longitud(<cadena>)

Examples that use it

Programs from the example library where it appears, from the simplest to the most complete.

  • Password Check

    Keeps asking for a password until it has at least 8 characters.

    Beginner
  • Name Initials

    Gets the initials of a full name.

    Beginner
  • Palindromes

    Checks whether a phrase reads the same forwards and backwards.

    Intermediate
  • Count Vowels

    Counts the vowels, spaces and other characters in a text.

    Intermediate
  • Data Formatting

    Fixes upper and lower case, and converts between text and numbers.

    Intermediate
  • Reusable Validation

    Validates the email and age on a sign-up form.

    Intermediate
See every Text example →

More string functions

Codoritmo is an independent, open-source project inspired by PSeInt and compatible with its syntax. It is not affiliated with the PSeInt project. Official PSeInt website.