Home > other >  Just small white primer Python consult with an open mind
Just small white primer Python consult with an open mind

Time:09-29

Two code has been an error
I asked baidu says it is type error may be a symbol of what
But I according to the given online classes of
Don't know what went wrong
Trouble, see the bosses to give directions

CodePudding user response:

In the python format not & amp; Symbol, is %

CodePudding user response:

reference 1/f, ice wind of reply:
format not in python & amp; Symbol, is %

Change is still the same result or incorrect

CodePudding user response:

The import string

S=input (" input a string: ")

Letter=0
Space=0
Digit=0
Other=0
For c in s:
If c.i salpha () :
Letter +=1
Elif c.i sspace () :
Space +=1
Elif c.i sdigit () :
Digit +=1
The else:
Other +=1

Print (f "letter {letter}, {space} space, {digit} digit, {other} other")

According to the format change, I just run is normal,

CodePudding user response:

refer to the second floor weixin_45935030 response:
Quote: refer to 1st floor ice all over the sky the wind response:
format not in python & amp; Symbol, is %

Change is still the same result or incorrect


 
The import string

S=input (" input a string: ")
Letter=0
Space=0
Digit=0
Other=0
For c in s:
If c.i salpha () :
Letter +=1
Elif c.i sspace () :
Space +=1
Elif c.i sdigit () :
Digit +=1
The else:
Other +=1

Print (' There are % d, % d Spaces, who \ % d
The % d and other characters in your string. '\
% (letter, space, digit, other))


Yes

CodePudding user response:

I tried it can run out thanks

CodePudding user response:

The
reference 3 floor zhangpeng188 response:
import string

S=input (" input a string: ")

Letter=0
Space=0
Digit=0
Other=0
For c in s:
If c.i salpha () :
Letter +=1
Elif c.i sspace () :
Space +=1
Elif c.i sdigit () :
Digit +=1
The else:
Other +=1

Print (f "letter {letter}, {space} space, {digit} digit, {other} other")

According to the format change, I just run is normal,

Thank you ~ can run out

CodePudding user response:

ice reference 4 floor of wind response:
Quote: refer to the second floor weixin_45935030 response:

Quote: refer to 1st floor ice all over the sky the wind response:
format not in python & amp; Symbol, is %

Change is still the same result or incorrect


 
The import string

S=input (" input a string: ")
Letter=0
Space=0
Digit=0
Other=0
For c in s:
If c.i salpha () :
Letter +=1
Elif c.i sspace () :
Space +=1
Elif c.i sdigit () :
Digit +=1
The else:
Other +=1

Print (' There are % d, % d Spaces, who \ % d
The % d and other characters in your string. '\
% (letter, space, digit, other))


Yes

I tried it can run out thanks

CodePudding user response:

S is a string, is not convenient, only dictionary list, tuples can be traversed

CodePudding user response:

The & amp; Changed to %, or use the format function
  • Related