Python Forum
checking if there are numbers in the string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
checking if there are numbers in the string
#1
flyTo = input("Where would you like to fly? ")
if flyTo == flyTo.isdigit():
    print("You accidentally added a number")
elif flyTo == flyTo.isalpha():
       print("Okay, we are going to {} ".format(flyTo))
else:
    print("??")
k don't laugh

no matter what is entered,
it says: "??"

I want it to check if there are numbers.. and if so, to say "you accidentally added a number"
how would i proceed with allowing letters, not numbers?

thanks
Reply


Messages In This Thread
checking if there are numbers in the string - by Sp00f - Apr-05-2017, 07:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pulling Specifics Words/Numbers from String bigpapa 2 791 May-01-2023, 07:22 PM
Last Post: bigpapa
  How do I check if the first X characters of a string are numbers? FirstBornAlbratross 6 1,581 Apr-12-2023, 10:39 AM
Last Post: jefsummers
  Checking if a string contains all or any elements of a list k1llcod3 1 1,137 Jan-29-2023, 04:34 AM
Last Post: deanhystad
  Find and Replace numbers in String giddyhead 2 1,259 Jul-17-2022, 06:22 PM
Last Post: giddyhead
  Finding line numbers starting with certain string Sutsro 3 2,575 Jun-27-2020, 12:36 PM
Last Post: Yoriz
  checking a string for two instances of .. Skaperen 2 1,605 May-13-2020, 09:58 PM
Last Post: Skaperen
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,768 May-09-2019, 12:19 PM
Last Post: Pleiades
  String format checking? MuntyScruntfundle 1 2,453 Mar-06-2019, 12:01 PM
Last Post: buran
  Extract numbers from string ian 1 2,835 Apr-28-2018, 10:40 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020