# Need guidance on my program error

**URL:** <https://forum.freecodecamp.org/t/need-guidance-on-my-program-error/441604>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [January 20, 2021, 6:59am UTC](https://forum.freecodecamp.org/t/need-guidance-on-my-program-error/441604 "2021-01-20T06:59:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yogavi](https://avatars.discourse-cdn.com/v4/letter/y/77aa72/32.png) [@yogavi](https://forum.freecodecamp.org/u/yogavi)\
**Post date:** [January 20, 2021, 6:59am UTC](https://forum.freecodecamp.org/t/need-guidance-on-my-program-error/441604/1 "2021-01-20T06:59:31Z")

</div>

I started learning Python only last week,I am trying to write a password set-up and validation program for practice. The below is the code

```auto
set_password = input('set-up your password: ')
set_password_length = len(set_password)

if set_password_length >= 8:
    elif set_password_length < 20:
        re_confirm_password = input('reenter your password: ')
    else:
        print('password cannot be longer than 20 characters')
        **break**
else:
    print('password should be minimum 8 characters long')
    **break**

if set_password == re_confirm_password:
    print('you have successfully set your password')
    login_password = set_password
else:
    print('please enter the same password')

number_of_attempt = 1
while number_of_attempt <= 3:
    number_of_attempt = number_of_attempt + 1
    enter_password = input('Enter your password: ')
    if enter_password == login_password:
        print('login successful')
        break
else:
    print('you exceeded the limit,your account is locked')

```

but python is complaining about the break statements .Can anybody help to understand the mistake and guide me.

Thank you.

---

<div class="post-metadata">

**Author:** ![sanity](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sanity/32/378897_2.png) [@sanity](https://forum.freecodecamp.org/u/sanity)\
**Post date:** [January 20, 2021, 8:28am UTC](https://forum.freecodecamp.org/t/need-guidance-on-my-program-error/441604/2 "2021-01-20T08:28:44Z")

</div>

`break` keyword can be used only within `while` or `for` loop, as an way to end that loop _earlier_ than waiting for `for` loop to iterate over all elements or `while` loop’s condition start to be `False`. Usually it’s used when certain additional condition, making further looping obsolete, is met.

---

<div class="post-metadata">

**Author:** ![Sky020](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sky020/32/128093_2.png) [@Sky020](https://forum.freecodecamp.org/u/Sky020)\
**Post date:** [January 20, 2021, 10:40am UTC](https://forum.freecodecamp.org/t/need-guidance-on-my-program-error/441604/3 "2021-01-20T10:40:31Z")

</div>

Welcome

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](http://www.freecodecamp.com/forum/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![yogavi](https://avatars.discourse-cdn.com/v4/letter/y/77aa72/32.png) [@yogavi](https://forum.freecodecamp.org/u/yogavi)\
**Post date:** [January 20, 2021, 12:43pm UTC](https://forum.freecodecamp.org/t/need-guidance-on-my-program-error/441604/4 "2021-01-20T12:43:39Z")

</div>

Thank you so much for your guidance.

---

<div class="post-metadata">

**Author:** ![yogavi](https://avatars.discourse-cdn.com/v4/letter/y/77aa72/32.png) [@yogavi](https://forum.freecodecamp.org/u/yogavi)\
**Post date:** [January 20, 2021, 12:44pm UTC](https://forum.freecodecamp.org/t/need-guidance-on-my-program-error/441604/5 "2021-01-20T12:44:29Z")

</div>

Sorry this was my very first post…i’ll definitely adhere to the practice in future.  
Thank you so much for support.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [July 22, 2021, 12:44am UTC](https://forum.freecodecamp.org/t/need-guidance-on-my-program-error/441604/6 "2021-07-22T00:44:32Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
