String methods in Python are easy 〰️

preview_player
Показать описание
#Python #string #methods

00:00:00 useful string methods
00:08:05 exercise

# name = input("Enter your name: ")
# phone_number = input("Enter your phone #: ")

# length = len(name)
Рекомендации по теме
Комментарии
Автор

#
# STRING METHODS
#
# name = input("Enter your name: ")
# phone_number = input("Enter your phone #: ")

# length = len(name)
# index = name.find(" ")
# name = name.capitalize()
# name = name.upper()
# name = name.lower()
# result = name.isdigit()
# result = name.isalpha()
# result = phone_number.count(" ")
# phone_number = phone_number.replace("-", "")

#
# EXERCISE
#
username = input("Enter a username: ")

if len(username) > 12:
print("Your name can't be more than 12 characters")
elif not username.find(" ") == -1:
print("Your username can't contain spaces")
elif not username.isalpha():
print("Your username can't contain digits")
else:
print(f"Welcome {username}!")

BroCodez
Автор

Every programming language is easy when explained by bro😎

S.H.I.E.L.D_EDITS
Автор

age = float(input('ENTER YOUR AGE: '))
if age >= 18:
b = input('ENTER YOUR USERNAME: ')
name= len(b)
if name > 12:
print('YOUR USERNAME IS MORE THAN 12 LETTERS')
elif b.count(' ') > 0 :
print('YOUR USERNAME CONTAINS A SPACE')
elif b.isdigit :
print('YOUR USERNAME CONTAINS A DIGIT')
else:
print(f"YOUR USERNAME IS SET TO '{b}' ")
else:
print('YOU MUST BE 18+ TO SIGN UP')

alizamalik
Автор

Hi Bro, Your HTMl, CSS and Javascript course is mind-blowing

elitegaming
Автор

This is THE BEST video about string methods on THE Excellent..It made me understand everything about string Thankk you Sir...

hussainmalik
Автор

You're the first person where I was able to solve the exercises at the end, I feel really proud of myself, thanks

enviableace
Автор

I love when you implement Exercises in your Videos! Im new to programming and love solving these on my own ;P like for example i checked for numbers using isdigit insead of isalpha but it still worked. Keep up the good work

therealestice
Автор

watching your videos as part of my revision :)

kszoknyik
Автор

I love how you include exercises in your videos .But i actually used this code in the exercise:
print('Username must not contain more than 12 letters')
print('Must not contain spaces')
print("And must not contain any digit")
print('')
user_n = input("Enter a username--")
len(user_n)
if len(user_n) > 12:
print("Invalid username as it has too many chracters.")
elif user_n.count(" ") != 0:#can/should also use user_n.find(" ")
print(f"Invalid username as it contains {user_n.count(" ")} space/s.")
elif user_n.isalpha() != True:
print(f"Invalid username as it has a digit/s.")
else:
print("Valid Username !You can sign up...")
This also works but one in the video is better

ChinzzaaaPizza
Автор

Holy shit, this taught me better than my programming teacher

ninjapirate
Автор

extremely well explained., ., thanks for your effort

iswebdb
Автор

x = input("Nickname: ")
while len(x) > 12 or len(x) == 0 or x.isalpha() == False:
print("cant be more then 12 characters and cant contain spaces and cant contain digits")
x = input("Nickname: ")
print("Hi!", x.capitalize())

ziggs
Автор

thank you for explaining this so well!

pcbgkhv
Автор

You're great man, i'm enjoying a lot this course

mateo
Автор

def checknum(text):
for i in text:
if i.isnumeric():
return False
else:
return True

username = input('enter username: ')

if len(username) <= 12 and username.find(' ') == -1 and checknum(username):
print('valid username')
else :
print('invalid username')

giornogiovanna
Автор

My Own Code! Still getting there as a beginner :)

print("---Welcome to SliceN'Dice---")

# Menu: Cheese Pizza, Pepperoni Pizza, Hawaiian Pizza, BBQ Pizza
pizza = input("What type pizza would you like to purchase? (CP, PP, HP, BBQ): ")
pizza_size = input("How big would you like your pizza to be? (S, M, L): ")

if pizza == "CP" and pizza_size == "S":
print("Here is your Small Cheese Pizza!")
elif pizza == "CP" and pizza_size == "M":
print("Here is your Medium Cheese Pizza!")
elif pizza == "CP" and pizza_size == "L":
print("Here is your Large Cheese Pizza!")
elif pizza == "PP" and pizza_size == "S":
print("Here is your Small Peperoni Pizza!")
elif pizza == "PP" and pizza_size == "M":
print("Here is your Medium Peperoni Pizza!")
elif pizza == "PP" and pizza_size == "L":
print("Here is your Large Peperoni Pizza!")
elif pizza == "HP" and pizza_size == "S":
print("Here is your Small Hawaiian Pizza!")
elif pizza == "HP" and pizza_size == "M":
print("Here is your Medium Hawaiian Pizza!")
elif pizza == "HP" and pizza_size == "L":
print("Here is your Large Hawaiian Pizza!")
elif pizza == "BBQ" and pizza_size == "S":
print("Here is your Small Barbeque Pizza!")
elif pizza == "BBQ" and pizza_size == "M":
print("Here is your Medium Barbeque Pizza!")
elif pizza == "BBQ" and pizza_size == "L":
print("Here is your Large Barbeque Pizza!")
else:
print(f"Error {pizza_size} {pizza} is not on the menu.")
print("Order something on the menu.")

AestheticBlue
Автор

Hello Everyone! My take on it is:

username=input(print("Enter Username:"))
if len(username)>12 or username.find(" ")>=0 or not username.isalpha():
print("Wrong username! It CANNOT: \n* be more than 12 characters\n* contain spaces\n* contain numbers ")
else:
print(f"Welcome {username}!")

stryjo
Автор

name = input("what is your name: ")
name = name.title()
sub1 = len(name)
if sub1 >=10:
print("name is grater then 10")
else:
print("hello, " + name)
age = int(input("how old are you: "))
if age >=100:
print("how are you even alive")
elif age <=10:
print("aww u just an ity bitty baby <3333")
else:
print(f"wow your {age} years old! good for you!!!")

yusra-wkgj
Автор

Your vids are incredibly helpful. How do you find or think of these practice programs?

TheMotorcycleBoss
Автор

What if I'm typing in spaces AND number, it only show "Your username cannot contains spaces" but not both

thecarzyguyyy