Cloud Stack Ninja

Given a string, print whether it is a number, word, or mixed with digit and letters. If all the characters are numeric values, print NUMBER. If they are all letters, print WORD. If it is mixed, print MIXED.

value = 'nka121fsd132'
for i in range(len(value)):
  if ((ord(value[i])>=65 and ord(value[i])<=90) or
   (ord(value[i])>=97 and ord(value[i])<=122)):
  elif (ord(value[i])>=48 and ord(value[i])<=57):
  elif (((ord(value[i])>=65 and ord(value[i])<=90) or
  (ord(value[i])>=97 and ord(value[i])<=122)) or 
  (ord(value[i])>=48 and ord(value[i])<=57)):

Its printing NUMBER here,not mixed

Read more here:

Content Attribution

This content was originally published by Kobra at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: