Welcome, guest | Sign In | My Account | Store | Cart

Necessary in commerce

Python, 10 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import re
print " Write  product  name  : "
nume_produs = raw_input()
print " Write product  price : "
cost_produs = input()
if (nume_produs == re.sub('[^a-z]',"",nume_produs)):
    print ('%s %d'%(nume_produs,cost_produs))
else:
    print "Error ! You  must tape letters"
input()

1 comment

Steven D'Aprano 6 years, 10 months ago  # | flag

I tried this, and it told me that "XBox 360" failed to validate. So did "Windows 7", "Levi's 501", "WD-40", and "V8 vegetable juice", all product names I either own or see in the shops. Perhaps your validation rule is too strict?

Created by Savu Andreea on Sun, 5 Oct 2014 (MIT)
Python recipes (4591)
Savu Andreea's recipes (1)

Required Modules

  • (none specified)

Other Information and Tasks