Limit number of characters is string | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Limit number of characters is string

How can I allow the user to enter a string with specific length? Ex Input 3 The user can write only ... three characters

17th Mar 2018, 10:45 AM
Ghaida
Ghaida - avatar
3 Answers
+ 11
U can display error message "read the instructions carefully"
17th Mar 2018, 11:53 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 5
You can either reject input longer or shorter than 3 characters, or automatically cut/fill it to 3.
17th Mar 2018, 10:56 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
I don’t want to reject the input I want to store the strings in array but all the strings must have length that already defined by the user
17th Mar 2018, 10:58 AM
Ghaida
Ghaida - avatar