Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge | While Loops: Essentials
Python Loops
course content

Contenido del Curso

Python Loops

Python Loops

1. While Loops: Get Started
2. While Loops: Essentials
3. For Loops
4. Nested Loops

Challenge

Palindrome Problem

You're doing well! It's time to solve the first algorithmic problem. In this task, you must check if the given word is a palindrome - a word that is equal to itself in reverse order. For instance::

aabaa is a palindrome

abcdef is not a palindrome

eerghgre is not a palindrome

s is a palindrome

This can be done using loops: for each pair of opposite characters, check if they are equal (1st and nth, 2nd and (n-1)th, etc.). The middle symbol (if any) is opposite to itself and is always equal. In this algorithm, compare each pair of symbols until such exist or you meet unequal ones.

If pair of unequal symbols occurs than word is no longer a palindrome, so you can skip other unchecked pairs and return the negative result. Even if the other pairs are equal symbols, word is no longer a palindrome.

Otherwise, if all pairs are checked and none symbols are unequal, the result is positive.

Don't be in a rush and think well about how it can be solved.

Tarea

Check if the given word is a palindrome. Print YES if it is and NO otherwise. Follow the comments in the task code and fill the gaps. Think about where you need to use the break keyword.

Think about corner cases when the word is empty or has one symbol: what will be the output? How can you process it?

Tarea

Check if the given word is a palindrome. Print YES if it is and NO otherwise. Follow the comments in the task code and fill the gaps. Think about where you need to use the break keyword.

Think about corner cases when the word is empty or has one symbol: what will be the output? How can you process it?

Follow up: What do you think about the next strings?

  • )(()())(
  • ())(((())(

Are they palindromic or not? Use your code to check them. The result might surprise you.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 2. Capítulo 6
toggle bottom row

Challenge

Palindrome Problem

You're doing well! It's time to solve the first algorithmic problem. In this task, you must check if the given word is a palindrome - a word that is equal to itself in reverse order. For instance::

aabaa is a palindrome

abcdef is not a palindrome

eerghgre is not a palindrome

s is a palindrome

This can be done using loops: for each pair of opposite characters, check if they are equal (1st and nth, 2nd and (n-1)th, etc.). The middle symbol (if any) is opposite to itself and is always equal. In this algorithm, compare each pair of symbols until such exist or you meet unequal ones.

If pair of unequal symbols occurs than word is no longer a palindrome, so you can skip other unchecked pairs and return the negative result. Even if the other pairs are equal symbols, word is no longer a palindrome.

Otherwise, if all pairs are checked and none symbols are unequal, the result is positive.

Don't be in a rush and think well about how it can be solved.

Tarea

Check if the given word is a palindrome. Print YES if it is and NO otherwise. Follow the comments in the task code and fill the gaps. Think about where you need to use the break keyword.

Think about corner cases when the word is empty or has one symbol: what will be the output? How can you process it?

Tarea

Check if the given word is a palindrome. Print YES if it is and NO otherwise. Follow the comments in the task code and fill the gaps. Think about where you need to use the break keyword.

Think about corner cases when the word is empty or has one symbol: what will be the output? How can you process it?

Follow up: What do you think about the next strings?

  • )(()())(
  • ())(((())(

Are they palindromic or not? Use your code to check them. The result might surprise you.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 2. Capítulo 6
toggle bottom row

Challenge

Palindrome Problem

You're doing well! It's time to solve the first algorithmic problem. In this task, you must check if the given word is a palindrome - a word that is equal to itself in reverse order. For instance::

aabaa is a palindrome

abcdef is not a palindrome

eerghgre is not a palindrome

s is a palindrome

This can be done using loops: for each pair of opposite characters, check if they are equal (1st and nth, 2nd and (n-1)th, etc.). The middle symbol (if any) is opposite to itself and is always equal. In this algorithm, compare each pair of symbols until such exist or you meet unequal ones.

If pair of unequal symbols occurs than word is no longer a palindrome, so you can skip other unchecked pairs and return the negative result. Even if the other pairs are equal symbols, word is no longer a palindrome.

Otherwise, if all pairs are checked and none symbols are unequal, the result is positive.

Don't be in a rush and think well about how it can be solved.

Tarea

Check if the given word is a palindrome. Print YES if it is and NO otherwise. Follow the comments in the task code and fill the gaps. Think about where you need to use the break keyword.

Think about corner cases when the word is empty or has one symbol: what will be the output? How can you process it?

Tarea

Check if the given word is a palindrome. Print YES if it is and NO otherwise. Follow the comments in the task code and fill the gaps. Think about where you need to use the break keyword.

Think about corner cases when the word is empty or has one symbol: what will be the output? How can you process it?

Follow up: What do you think about the next strings?

  • )(()())(
  • ())(((())(

Are they palindromic or not? Use your code to check them. The result might surprise you.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Palindrome Problem

You're doing well! It's time to solve the first algorithmic problem. In this task, you must check if the given word is a palindrome - a word that is equal to itself in reverse order. For instance::

aabaa is a palindrome

abcdef is not a palindrome

eerghgre is not a palindrome

s is a palindrome

This can be done using loops: for each pair of opposite characters, check if they are equal (1st and nth, 2nd and (n-1)th, etc.). The middle symbol (if any) is opposite to itself and is always equal. In this algorithm, compare each pair of symbols until such exist or you meet unequal ones.

If pair of unequal symbols occurs than word is no longer a palindrome, so you can skip other unchecked pairs and return the negative result. Even if the other pairs are equal symbols, word is no longer a palindrome.

Otherwise, if all pairs are checked and none symbols are unequal, the result is positive.

Don't be in a rush and think well about how it can be solved.

Tarea

Check if the given word is a palindrome. Print YES if it is and NO otherwise. Follow the comments in the task code and fill the gaps. Think about where you need to use the break keyword.

Think about corner cases when the word is empty or has one symbol: what will be the output? How can you process it?

Follow up: What do you think about the next strings?

  • )(()())(
  • ())(((())(

Are they palindromic or not? Use your code to check them. The result might surprise you.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 6
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt