+ 3
Write a program if name is less than 3 characters long, name must be at least 3 characters otherwise if its more than 50 chara
4 Réponses
+ 8
Chama Kazadi ,
you can do it like:
▪︎take a string input and assign it to a variable
▪︎get the length of the string by using the builtin function len()
▪︎use a conditional statement with if.... that checks wether the length of the string is in the required range
if conditional is True: output whatever message is needed
▪︎use an else clause that automatically covers all other cases
output whatever message is needed
i would also recommend you to start learning from one ofcthe python tutorials.
happy coding and good success!
+ 3
Hello, Chama!
Here you have my code:
https://code.sololearn.com/cc9OF6vleH0f/?ref=app
I explain this code to you.
First I make a variable called name which is an input converted to a list. Then I make an if conditional that is if the name is less than 3 characters or the name is exceeded 50 characters, if this happens I make a while loop with the same conditions as the if, its function is to repeat the name variable that is the same at the beginning. At the end I convert the name to string and print it.
Any questions just ask me.
+ 2
Thank you very this has really opened up my eyes
+ 1
Thanks buddy