# Given nums, use a for-else loop to search for the first negative number

Canonical URL: <https://datadriven.io/problems/given-nums-use-a-for-else-loop-to-search-for-the-first-nega-13a35b1f>

Domain: Python · Difficulty: medium

## Problem

Given nums, use a for-else loop to search for the first negative number. If found, print 'Found: ' followed by the number and break. If no negative number exists, the else block should print 'All positive'.

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/given-nums-use-a-for-else-loop-to-search-for-the-first-nega-13a35b1f)
- [Python Interview Questions](https://datadriven.io/python-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.