Input function with Try and Except | User input in Python

Опубликовано: 01 Январь 1970
на канале: SnekCato
358
41

Here you will learn how to use the input function and try and except in your code.

The input function asks the user to enter a value, converts into string and sends it back to you.
In “try” we put the line we know it may cause trouble. In this case, the line that transforms the input into integers.
In "except", we are going to include the error message instead of letting python blow up.

Do you like Horror games? Follow me on Twitch! :   / snekcato  
Join our community of tech catos :   / discord  

Timestamps
0:00 Intro
0:47 Input example
1:04 How to include an instruction inside input?
1:30 Task with input ()
1:45 Task answer
2:53 Improved task answer
4:13 Thanks for watching!


Code for the love function:

def love():
amount_love= input ("How much do you love me?: ")
try:
amount_love= int(amount_love)
print(f"I love you {amount_love*2}")
except:
print("That is not a number")
love()


На этой странице сайта вы можете посмотреть видео онлайн Input function with Try and Except | User input in Python длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь SnekCato 01 Январь 1970, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 358 раз и оно понравилось 41 зрителям. Приятного просмотра!