SlideShare una empresa de Scribd logo
1 de 1
Descargar para leer sin conexión
Can you code in python. Thank you!
Ask a user to repeatedly enter the two stings. Keep asking the user to enter new strings until both
stings have a length greater than 0 . Use function len() to find the length of a string. Check if two
strings have the same length (the same number of letters/characters in the string) - If they are not
the same, print 'Strings do not match in length' and prompt the user to enter the words again.
Have them enter both strings again (it may be helpful to ask the user to enter the strings of the
same length) - If they have the same length - Use nested loops to iterate through both strings -
Compare each letter in the first string to each letter in the second string - If a letter of the first string
is in the second string and in the same spot, write: ' w is in the input 2 string and in the correct spot
1 ' where w is the letter you are checking and 1 is the position in both strings Print 'Correct letters
in correct spot: X ' where X is the number of correct letters in the correct spot discovered so far. - If
a letter of the first string is in the second string but in a different spot, write: ' o is in the input_2
string but not in the correct spot' - If all the letters in both strings are the same, write: 'Strings are
the same' How will you determine this case? Use only while loop, for loop, if (if-else, if-elif-else)
statement, !=, =, print (, len( ) and range() functions. Example #1:Example #3 If the inputs are The
output is: You entered 2 1-letter strings which will be followed by two prompts Enter string 1: and
Enter string 2: ... Example #4 If the inputs are mochi mochi The output is: You entered 2 5-letter
strings m is in the input 2 string and in the correct spot 1 Correct letters in the correct spot: 1 o is in
the input 2 string and in the correct spot 2 Correct letters in the correct spot: 2 c is in the input 2
string and in the correct spot 3 Correct letters in the correct spot: 3 h is in the input 2 string and in
the correct spot 4 Correct letters in the correct spot: 4 i is in the input 2 string and in the correct
spot 5 Correct letters in the correct spot: 5 The strings are the same which will be followed by two
prompts Enter string 1: and Enter string 2: Example #5 If the inputs areThe output is: You entered
2 2-letter strings a is in the input 2 string and in the correct spot 1 Correct letters in the correct
spot: 1 a is in the input 2 string but not in the correct spot which will be followed by two prompts
Enter string 1 : and Enter string 2: ... Hint: To iterate through a string, you can use range and
indexing as shown below: my_string = 'Mochi' for i in range(len(my_string)): print(my_string[i])

Más contenido relacionado

Similar a Can you code in python Thank you Ask a user to repeatedly .pdf

Notes3
Notes3Notes3
Notes3
hccit
 

Similar a Can you code in python Thank you Ask a user to repeatedly .pdf (10)

Notes3
Notes3Notes3
Notes3
 
String in python lecture (3)
String in python lecture (3)String in python lecture (3)
String in python lecture (3)
 
Acm aleppo cpc training third session
Acm aleppo cpc training third sessionAcm aleppo cpc training third session
Acm aleppo cpc training third session
 
Introduction to cryptography and types of ciphers
Introduction to cryptography and types of ciphersIntroduction to cryptography and types of ciphers
Introduction to cryptography and types of ciphers
 
Python Strings Methods
Python Strings MethodsPython Strings Methods
Python Strings Methods
 
Unit i pyton ref
Unit i pyton refUnit i pyton ref
Unit i pyton ref
 
HackerRank Repeated String Problem
HackerRank Repeated String ProblemHackerRank Repeated String Problem
HackerRank Repeated String Problem
 
Strings.pptx
Strings.pptxStrings.pptx
Strings.pptx
 
UNIT 4 python.pptx
UNIT 4 python.pptxUNIT 4 python.pptx
UNIT 4 python.pptx
 
unit-4 regular expression.pptx
unit-4 regular expression.pptxunit-4 regular expression.pptx
unit-4 regular expression.pptx
 

Más de akshpatil4

can you help me write this code in Net Maui App please than.pdf
can you help me write this code in Net Maui App please than.pdfcan you help me write this code in Net Maui App please than.pdf
can you help me write this code in Net Maui App please than.pdf
akshpatil4
 
Can You build the web based project Homepage for me Home .pdf
Can You build the web based project Homepage for me   Home .pdfCan You build the web based project Homepage for me   Home .pdf
Can You build the web based project Homepage for me Home .pdf
akshpatil4
 
Can You build the web based project for me Home Page Aft.pdf
Can You build the web based project for me   Home Page Aft.pdfCan You build the web based project for me   Home Page Aft.pdf
Can You build the web based project for me Home Page Aft.pdf
akshpatil4
 
can you break this down in python codes please Task 1 Cre.pdf
can you break this down in python codes please  Task 1 Cre.pdfcan you break this down in python codes please  Task 1 Cre.pdf
can you break this down in python codes please Task 1 Cre.pdf
akshpatil4
 
Can someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdfCan someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdf
akshpatil4
 
Can someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdfCan someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdf
akshpatil4
 
Can someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdfCan someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdf
akshpatil4
 
can someone please assist me with analysis of this case atud.pdf
can someone please assist me with analysis of this case atud.pdfcan someone please assist me with analysis of this case atud.pdf
can someone please assist me with analysis of this case atud.pdf
akshpatil4
 
Can someone help with these functions doAddTweet doEditTwe.pdf
Can someone help with these functions  doAddTweet doEditTwe.pdfCan someone help with these functions  doAddTweet doEditTwe.pdf
Can someone help with these functions doAddTweet doEditTwe.pdf
akshpatil4
 

Más de akshpatil4 (20)

Calculate the amount of money Paige had to deposit in an inv.pdf
Calculate the amount of money Paige had to deposit in an inv.pdfCalculate the amount of money Paige had to deposit in an inv.pdf
Calculate the amount of money Paige had to deposit in an inv.pdf
 
Cada ao en los Estados Unidos cientos de iglesias cristian.pdf
Cada ao en los Estados Unidos cientos de iglesias cristian.pdfCada ao en los Estados Unidos cientos de iglesias cristian.pdf
Cada ao en los Estados Unidos cientos de iglesias cristian.pdf
 
Can you please add comments so I can understand it Thank yo.pdf
Can you please add comments so I can understand it Thank yo.pdfCan you please add comments so I can understand it Thank yo.pdf
Can you please add comments so I can understand it Thank yo.pdf
 
can you help me write this code in Net Maui App please than.pdf
can you help me write this code in Net Maui App please than.pdfcan you help me write this code in Net Maui App please than.pdf
can you help me write this code in Net Maui App please than.pdf
 
Can you help me with these two questions I will give you a .pdf
Can you help me with these two questions I will give you a .pdfCan you help me with these two questions I will give you a .pdf
Can you help me with these two questions I will give you a .pdf
 
Can you help me design this interface in HTML Flight Find.pdf
Can you help me design this interface in HTML   Flight Find.pdfCan you help me design this interface in HTML   Flight Find.pdf
Can you help me design this interface in HTML Flight Find.pdf
 
Can You build the web based project Homepage for me Home .pdf
Can You build the web based project Homepage for me   Home .pdfCan You build the web based project Homepage for me   Home .pdf
Can You build the web based project Homepage for me Home .pdf
 
Can You build the web based project for me Home Page Aft.pdf
Can You build the web based project for me   Home Page Aft.pdfCan You build the web based project for me   Home Page Aft.pdf
Can You build the web based project for me Home Page Aft.pdf
 
can you break this down in python codes please Task 1 Cre.pdf
can you break this down in python codes please  Task 1 Cre.pdfcan you break this down in python codes please  Task 1 Cre.pdf
can you break this down in python codes please Task 1 Cre.pdf
 
Can someone explain this to me step by step Consider a give.pdf
Can someone explain this to me step by step Consider a give.pdfCan someone explain this to me step by step Consider a give.pdf
Can someone explain this to me step by step Consider a give.pdf
 
Can you answer these True or False questions for me please .pdf
Can you answer these True or False questions for me please .pdfCan you answer these True or False questions for me please .pdf
Can you answer these True or False questions for me please .pdf
 
Can someone please help with this Now that you have compl.pdf
Can someone please help with this  Now that you have compl.pdfCan someone please help with this  Now that you have compl.pdf
Can someone please help with this Now that you have compl.pdf
 
Can someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdfCan someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdf
 
Calculate the amount of money Dylan had to deposit in an inv.pdf
Calculate the amount of money Dylan had to deposit in an inv.pdfCalculate the amount of money Dylan had to deposit in an inv.pdf
Calculate the amount of money Dylan had to deposit in an inv.pdf
 
Can someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdfCan someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdf
 
Can someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdfCan someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdf
 
can someone please assist me with analysis of this case atud.pdf
can someone please assist me with analysis of this case atud.pdfcan someone please assist me with analysis of this case atud.pdf
can someone please assist me with analysis of this case atud.pdf
 
can someone help me with this class ENVS 200040 Pollution.pdf
can someone help me with this class ENVS 200040   Pollution.pdfcan someone help me with this class ENVS 200040   Pollution.pdf
can someone help me with this class ENVS 200040 Pollution.pdf
 
Can someone help me with these questions 1 Main structures.pdf
Can someone help me with these questions 1 Main structures.pdfCan someone help me with these questions 1 Main structures.pdf
Can someone help me with these questions 1 Main structures.pdf
 
Can someone help with these functions doAddTweet doEditTwe.pdf
Can someone help with these functions  doAddTweet doEditTwe.pdfCan someone help with these functions  doAddTweet doEditTwe.pdf
Can someone help with these functions doAddTweet doEditTwe.pdf
 

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Can you code in python Thank you Ask a user to repeatedly .pdf

  • 1. Can you code in python. Thank you! Ask a user to repeatedly enter the two stings. Keep asking the user to enter new strings until both stings have a length greater than 0 . Use function len() to find the length of a string. Check if two strings have the same length (the same number of letters/characters in the string) - If they are not the same, print 'Strings do not match in length' and prompt the user to enter the words again. Have them enter both strings again (it may be helpful to ask the user to enter the strings of the same length) - If they have the same length - Use nested loops to iterate through both strings - Compare each letter in the first string to each letter in the second string - If a letter of the first string is in the second string and in the same spot, write: ' w is in the input 2 string and in the correct spot 1 ' where w is the letter you are checking and 1 is the position in both strings Print 'Correct letters in correct spot: X ' where X is the number of correct letters in the correct spot discovered so far. - If a letter of the first string is in the second string but in a different spot, write: ' o is in the input_2 string but not in the correct spot' - If all the letters in both strings are the same, write: 'Strings are the same' How will you determine this case? Use only while loop, for loop, if (if-else, if-elif-else) statement, !=, =, print (, len( ) and range() functions. Example #1:Example #3 If the inputs are The output is: You entered 2 1-letter strings which will be followed by two prompts Enter string 1: and Enter string 2: ... Example #4 If the inputs are mochi mochi The output is: You entered 2 5-letter strings m is in the input 2 string and in the correct spot 1 Correct letters in the correct spot: 1 o is in the input 2 string and in the correct spot 2 Correct letters in the correct spot: 2 c is in the input 2 string and in the correct spot 3 Correct letters in the correct spot: 3 h is in the input 2 string and in the correct spot 4 Correct letters in the correct spot: 4 i is in the input 2 string and in the correct spot 5 Correct letters in the correct spot: 5 The strings are the same which will be followed by two prompts Enter string 1: and Enter string 2: Example #5 If the inputs areThe output is: You entered 2 2-letter strings a is in the input 2 string and in the correct spot 1 Correct letters in the correct spot: 1 a is in the input 2 string but not in the correct spot which will be followed by two prompts Enter string 1 : and Enter string 2: ... Hint: To iterate through a string, you can use range and indexing as shown below: my_string = 'Mochi' for i in range(len(my_string)): print(my_string[i])