Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to find 1 st digit in python

# Python Program to get the first digit of number

# take input
num = int(input('Enter any Number: '))

# convert int to string
num_str = str(num)

# get the first digit
first_digit = num_str[0]

# printing first digit of number
print('The first digit of number:', first_digit)
Comment

PREVIOUS NEXT
Code Example
Python :: python convert string to float array 
Python :: convert decimal to hex python 
Python :: get ContentType with django get_model 
Python :: input command in python shell 
Python :: convert price to float python 
Python :: sort a string in python 
Python :: dataframe from dict 
Python :: enable debug mode flask 
Python :: check if path exists python 
Python :: django cookies 
Python :: how to open application using python 
Python :: python open and read file with 
Python :: python push to list 
Python :: isnull().mean() python 
Python :: json python 
Python :: how to get index of closest value in list python 
Python :: how to sort a dictionary py 
Python :: pyplot width 
Python :: string remove everything after character python 
Python :: use a dictionary to make a column of values 
Python :: Change my python working directory 
Python :: pandas drop column in dataframe 
Python :: error handling flask 
Python :: python random list 
Python :: change django time zone 
Python :: nn.dropout 
Python :: python kill all threads 
Python :: delete migrations django and start over deployment heroku 
Python :: apply same shuffle to two arrays numpy 
Python :: import qq plot 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =