Menu
CoddyTech

Recap - Username Check

Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 5 of 78.

challenge icon

Challenge

Easy

The program reads a username that a player typed into raw. First clean it: remove the spaces at both ends and convert it to lowercase. The cleaned username is valid when all of these rules pass:

  • It has between 3 and 16 characters, both included
  • It contains no spaces
  • It does not begin with a digit (0 to 9)
  • It contains none of the characters !, ? and .

Print ok: followed by the cleaned username when it is valid, otherwise print bad. For the input Alice42 (with spaces around it), the output is:

ok: alice42

Try it yourself

extends Node

func _ready():
	var raw := OS.read_string_from_stdin()
	# Clean the username, check the rules, print the result

All lessons in Logic & Flow

Practice on your own: Online GDScript compiler