Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python Expression expected ; Statement expected

Pamedi

New Coder
So hey guys I am totally new to coding and I tried to make a programm that would show me my recipe for my pancakes etc. if I type a certain number from 1 to 3 in there.
But it came with a couple problems I dont know how to solve since this is my first time. the first is at print(for) and the next one is at the end of the line at ]:) appreciate your help in advance and bless you all

portions = 1
Pfannkuchen = '1'
Waffeln = '2'
Schokokuchen = '3'

Rezept = input('Bitte geben Sie Ihr Rezept an: ')

is_Pfannkuchen = 1
is_Waffeln = 2
is_Schokokuchen = 3

if is_Pfannkuchen:
print(for x in [str(portions * 0.5) + '2Eier', '200 g Mehl', '200 ml Milch', '1 Prise Salz', '60 ml Wasser', '1 Prise Zucker']:)
print(x)

elif is_Waffeln:
print(for x in [str(portions * 0.5) + '3 Eier', '200 g Mehl', '200 ml Milch', '1 Prise Salz', '1 Backpulver', '1 Prise Zucker']:)
print(x)

elif is_Schokokuchen:
print(for x in [str(portions * 0.5) + '3 Eier', '200 g Mehl', '200 ml Milch', '1 Tafel Schokolade', '1 Backpulver', '1 Prise Zucker']:)
print(x)

else:
print('Bitte Geben Sie eine Zahl von 1-3 an')
 
Okay I will try thanks, I just imagined some numbers so dont wonder please


portions = 1
Pancake = '1'
Waffels = '2'
cake = '3'



Recipe = input('Please type in your recipe')

is_Pancake = 1
is_waffles = 2
is_cake = 3

if is_Pancake:
print(for x in [str(portions * 0.5) + '2 eggs', '200 flour g ', '200 ml milk', '5 gramm salt', '60 ml Water', '5 gramm sugar']:)
print(x)

elif is_Waffles:
print(for x in [str(portions * 0.5) + '3 Eggs', '200 g flour', '200 ml Milk', '5 gramm salt', '1 pack of pulver', '15 gramm sugar']:)
print(x)

elif is_cake:
print(for x in [str(portions * 0.5) + '3 Eggs', '200 g flour', '200 ml Milk', 'chocolate', '1 pack of pulver', ' 20 gramm sugar']:)
print(x)

else:
print('Please Type in a number from 1-3 to get your wished recipe')
 
You are not comparing the input to chosen recipe.

I've modified the code to one way it could be written

Python:
portions = 1
pancake = 1
waffles = 2
cake = 3

print('please choose a number from 1 - 3')
recipe = input('>> ') # Get the input
recipe = int(recipe) # Convert to int

# Compare input to one of the numbers entered (recipe)
# assign meg variable
if recipe == 1:
    msg = f'Portions: {portions * 0.5} - 3 eggs, 200 g flour, 200 ml milk 5 gram salt, 60 ml water, 5 gram sugar'
elif recipe == 2:
    msg = f'Portions: {portions * 0.5} - 3 Eggs, 200 g flour, 200 ml Milk, 5 gramm salt, 1 pack of pulver, 15 gramm sugar'
elif recipe == 3:
    msg = f'Portions: {portions * 0.5} - 3 Eggs, 200 g flour, 200 ml Milk, chocolate, 1 pack of pulver, 20 gramm sugar'
else:
    msg = 'Invalid input'

# Print the msg
print(msg)

Output
Code:
please choose a number from 1 - 3
>> 2
Portions: 0.5 - 3 Eggs, 200 g flour, 200 ml Milk, 5 gramm salt, 1 pack of pulver, 15 gramm sugar
 

New Threads

Buy us a coffee!

Back
Top Bottom