• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Python Help !

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the given prompt: Write a loop to see if a has any letter that comes before b in the alphabet. (assume all letters are lowercase)
(Line of code)

a = input("type a word: ")
b = input("type a letter: ")  

This is what I have so far:


contains = False
for char in s:


( also how would you solve this with a while loop and for-range?)

I'm new here pleases don't be too harsh
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mina Asj wrote:
I'm new here pleases don't be too harsh



We are never harsh!  
Start simple.  Try to prompt the user for a string, then print out the characters in the string one by one.  Once you have that working, you can try to add a comparison in the loop.

Mina Asj wrote:
also how would you solve this with a while loop and for-range?



Once you get the first task done, you'll understand a little more about looping and testing.  Then you can consider how to do it with other loop types.  
While loops are documented here
For loops are documented here

If you have further questions, don't hesitate to ask.  We are happy to help, but we want you to do the work so you can learn.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic