0

I have an assignment were we're supposed to write a script for pig latin, I have the base done but I need to detect so that it doesn't contain a number or are several words

I've tried a lot of if statements and other things, none have worked this far.

word1 = input("Write a word in English: ")
siffra = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
for x in siffra:
    if x in word1 or word1.count(" "):
        print("Bara ett ord och inga siffor!")
        break
    else:
        pig = word1[1:] + word1[0] + "ay"
        print(pig.lower())
        break 

I want it to say "Bara ett ord och inga siffror" when there is a number in word1. But now it only says that when there is a 1 in word1.

Georgy
  • 12,464
  • 7
  • 65
  • 73
SaltyGaben
  • 11
  • 3

1 Answers1

0

I found a solution, here's the code

word1 = input("Write a word in English: ")
if word1.isalpha() == False or word1.count(" "):
    print("Bara ett ord och inga siffor!")
else:
    pig = word1[1:] + word1[0] + "ay"
    print(pig.lower())
SaltyGaben
  • 11
  • 3