• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Python Help !

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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: 9615
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • 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.
 
I love a good mentalist. And so does this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic