#basic python

21 messages · Page 1 of 1 (latest)

gloomy storm
#

I'm trying to get it so that if the user types yes then the program prints the list.. but it wont work can anyone help?

umbral cargo
#

Remove the int()

gloomy storm
#

ah thanks is there a way to make it so when the list is printed the brackets and commas arent showed?

umbral cargo
#

You can loop and print each thing or use join

#

!exec

my_awesome_list = ["foo", "bar", "baz"]
for word in my_awesome_list:
    print(word, end=" ")
print()

print(" ".join(my_awesome_list))
hybrid yewBOT
umbral cargo
#

!exec

my_awesome_list = ["foo", "bar", "baz"]
print(*my_awesome_list, sep=" ")
hybrid yewBOT
umbral cargo
#

Or splat too

gloomy storm
#

any easier way?

umbral cargo
#

Not that I'm aware of off the top of my head, I don't think any of them aren't easy?

gloomy storm
#

items=["iphone12","iphone11","iphone10","PS5","PS4","XBOX","computer"]
yesorno=input ("Hello! This program gives you a price for certain devices. Would you like to continue?")
if yesorno == "yes":
print*(items, sep=" ")
else:
print("Oh, ok see you soon")

#

would this worl

#

work

umbral cargo
#

The * needs to be inside te brackets but I don't see why not other than that 🙂

gloomy storm
#

thanks alot it workds

#

could you put this is the list before the *?

umbral cargo
#

What do you mean?

gloomy storm
#

doesnt matter I did it

umbral cargo
#

Okay 🙂

gloomy storm
#

items=["iphone12","iphone11","iphone10","PS5","PS4","XBOX","computer"]
iphone12=1000
iphone11=700
iphone10=500
PS5=600
PS4=200
XBOX=200
computer=800
yesorno=input ("Hello! This program gives you a price for certain devices. Would you like to continue?")
if yesorno == "yes":
print("these are you choices:",*items, sep=" ")

else:
print("Oh, ok see you soon")

amount=int(input("What is the quantity of your order?"))
total=amount*items