If/elif/else
elif is used if the previous condition is not met, but the current one is.
12345678price = 999 if price > 1000: print('The price is high. I won't buy it') elif price > 500: print('I will think if I need it') else: print('I will definitely buy it')
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 4
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Suggested prompts:
Ställ mig frågor om detta ämne
Sammanfatta detta kapitel
Visa verkliga exempel
Fantastiskt!
Completion betyg förbättrat till 2.7
If/elif/else
Svep för att visa menyn
elif is used if the previous condition is not met, but the current one is.
12345678price = 999 if price > 1000: print('The price is high. I won't buy it') elif price > 500: print('I will think if I need it') else: print('I will definitely buy it')
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 4