Whatever the user inputs is taken as a string by pthon. Even if it is a number. u can print all the potions like in the video, then you can do something like this. else: print("You didnt put a valid number")
Class business: Def __init__(self,employee): self.employee = employee (I think you would enter a similar code with "value" in)be more precise with what you are trying to say and then you can be helped)
Excellent example for practising dictionaries and understanding how to use them within a loop. Thank you very much
I found your video very helpful with an interesting set of examples. Thank you very much !
short and sweet code plus explanation...well done.
Good example , very good color on screen . Thanks a lot .
amazing example for dictionary with this video you can clearly understand the concept of this like + subscribe congratulations for your job :)
Thank you very much for the wonderful explanation i struggle to understand dictonary
Thank you so much..It really helped !
thanks i did the program , but when choose option 1 i can not move to another option , why ?
Very interesting indeed but how this be done with a class as marketshop?
Thank you for sharing. This is my version of the code:
import os
import time
Basket={}
print("""
1. Add Item
2. Remove Item
3. View Basket
0. Exit
""")
option=int(input("Enter an Option: "))
while option!=0:
try:
if option==1:
Item=input("Enter Item: ")
qty=int(input("Enter Quantity: "))
if Item in Basket:
Basket[Item]+=qty
else:
Basket[Item]=qty
print("Saved")
elif option==2:
Item=input("Enter Item to Delete: ")
del(Basket[Item])
print("Deleted")
elif option==3:
if len(Basket)==0:
print("Baksket is Empty.")
else:
for Item in Basket:
print(Item,": ",Basket[Item])
elif option!=0:
print("Wrong Option Enter.")
time.sleep(5)
os.system("clear") # or cls
print("""
1. Add Item
2. Remove Item
3. View Basket
0. Exit
""")
option=int(input("Enter Option: "))
except Exception as e:
print("Wrong information Enter. Try again.")
time.sleep(5)
os.system("clear")
print("""
1. Add Item
2. Remove Item
3. View Basket
0. Exit
""")
option=int(input("Enter Option: "))
print("Basket Closed.")
Thank you so much
Perfect!!!! Thanks!
Could not see the programing code lines.. please incease your font size or zoom the screen
Thank you brother
Pls share the code
What would I do if I wanted an option for if the user entered a string? I tried
elif option == str:
print('-Enter valid number-')
it was no good
Whatever the user inputs is taken as a string by pthon. Even if it is a number.
u can print all the potions like in the video, then you can do something like this.
else:
print("You didnt put a valid number")
option = input("give a option:")
elif option == "str":
print("-Enter valid number-")
shopping_basket = {}
print("""
Shopping Basket Options
----------------------
1: Add item
2: Remove item
3: view basket
0: Exit program
""")
while True:
try:
option = int(input("Enter an option: "))
while option != 0:
if option == 1:
item = input("Enter an item: ")
if item in shopping_basket:
print("items exists already!")
quantity = int(input("Enter the quantity: "))
shopping_basket[item] += quantity
else:
quantity = int(input("Enter the quantity: "))
shopping_basket[item] = quantity
elif option == 2:
item = input("Enter an item: ")
if item in shopping_basket:
del (shopping_basket[item])
else:
print("item doesn't exist in shopping basket")
elif option == 3:
print(shopping_basket)
for item in shopping_basket:
print(item, ':', shopping_basket[item])
elif option != 0:
print("you didn't enter a valid number")
option = int(input("
Enter an option: "))
except ValueError:
print("please enter a valid number")
How to add a employee class object and how to print the value using looping
Class business:
Def __init__(self,employee):
self.employee = employee
(I think you would enter a similar code with "value" in)be more precise with what you are trying to say and then you can be helped)
audio is not upto scratch....
Can't see in mobile .. plz zoom ..
sad
First
AwesomeAlex1337 shall be last