Skip to content

Forum in maintenance, we will back soon 🙂

Notifications
Clear all

Homework Loops

2 Posts
2 Users
3 Reactions
61 Views
(@cindy-jacks)
Posts: 3
Active Member Customer
Topic starter
 

First I just asked verbally and ChatGPT gave me this answer:

```python
for num in range(1, 11)
if num % 2 != 0:
print(num)

else:
print("Even number detected!")

I tried it and it worked.

Then I copy/pasted your "hint" and it gave me this answer:

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for number in numbers:
if number % 2 != 0:
print(number)
else:
print("Even number detected!")

I see I can write "for num in range(1, 11)" (vs typing out each number)

ChatGPT does in a blink what I would have struggled with for hours maybe.

It's like alien intelligence willing to answer my questions.

 
Posted : 07/01/2023 5:04 am
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

The most important thing here it to understand the output. And don't just reply on chatgpt.

 
Posted : 07/01/2023 7:48 pm
SSAdvisor reacted
Share:
[the_ad_group id="312"]