Recap - Username Check
Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 5 of 78.
Challenge
EasyThe 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
3and16characters, both included - It contains no spaces
- It does not begin with a digit (
0to9) - 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: alice42Try 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
1Strings In Depth
String MethodsSearching in StringsReplace and TrimSplit and JoinRecap - Username Check4Dictionaries Part 2
Nested DictionariesArrays of DictionariesMerging DictionariesCopying DictionariesRecap - Frequency Counter2Advanced Decision Making
Match With VariablesMatch GuardsArray PatternsDictionary PatternsMembership ChecksRecap - Command Parser5Contact Book Application
Display MenuAdd Contact8Student Records Manager
Project OverviewAdd Student3Multi-dimensional Arrays
2D Arrays BasicsAccessing 2D Array ElementsNested Loops with 2D ArraysRecap - 2D ArraysJagged ArraysCommon 2D Array PatternsRecap - Game Board6Sets with Dictionaries
What is a Set?Dictionary as a SetAdding and RemovingUnion and IntersectionSet DifferenceRecap - Remove Duplicates9Advanced Data Aggregation
Summing ValuesFinding Minimum and MaximumCustom SortingRecap - Dictionary SorterPractice on your own: Online GDScript compiler