Greetings Edmundo!

On Thu, Sep 7, 2017 at 1:35 PM, Peter Otten <__pete...@web.de> wrote:
> edmundo pierre via Tutor wrote:
>
>>
>> I am trying to write a code that asks an User to Enter a decimal number,
>> the my program should separate the number in two parts like this: 1
>> cae:Enter a number: 12.9Decimal part: 12whole part : 9 2 case:Enter:
>> 10Decimal par:Whole part: 10 That is my code:
>> A = input("Enter a number")
>> C = [ ]     for  i  in  str(A) :
>> C.append(i)      if i ==".# period ":         break      aa= "".join(c)
>> print(aa, end =" ") if i == int(A):         print(" It is the whole part")
>> I can not display the whole part when I enter float number. Plus when I
>> enter an integer, it takes that enteger as a decimal number. Any help?
>
> Hello Edmundo!
>
> We are all volunteers. Please help us help you. If you have a look at
>
> https://mail.python.org/pipermail/tutor/2017-September/111984.html
>
> you can see what we see of your code. It's completely garbled, and second-
> guessing what it might originally have looked like is no fun.
>
> You have to find out how to get your email program to send unmodified plain
> text before we can engage in a meaningful conversation.

I'd like to augment Peter's request:  Please use a more informative
subject line than "Help".  I notice you have posted two "Help" emails
recently on two substantially different topics.

As to the most current topic, your code is garbled to me as well, but
it looks like you realize that input() returns a string, not a float,
and that you are trying to use string methods to get what you want.
Another approach you might want to look into is using float(input())
to convert the string resembling a float into a floating point number
and then use the operator "//" (to perform integer division) and then
use that result to extract the decimal portion.  You will still have
to work on dealing with the decimal point removal and just getting the
decimal fraction as just integer-like numbers, but that is not too
hard ...

-- 
boB
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to